From d56c723b5144e2406199eac8be41008443c493dc Mon Sep 17 00:00:00 2001 From: dvince Date: Mon, 29 Apr 2024 14:29:39 -0400 Subject: [PATCH 1/6] task[hmi-server] - server cleanup * Did some legwork for future database work, bringing `description` and `name` into the parent `TerariumAsset` class, and updating all the tests for that. * Changing the data type of `description` to be text for future proofing. * Explicitly define string length on the two classes we've migrated so far * Wrote needed migrations. --- packages/client/hmi-client/src/types/Types.ts | 16 +-- .../hmiserver/models/TerariumAsset.java | 8 ++ .../models/dataservice/Artifact.java | 7 - .../models/dataservice/code/Code.java | 6 - .../dataservice/concept/ActiveConcept.java | 1 - .../models/dataservice/dataset/Dataset.java | 7 - .../dataservice/document/DocumentAsset.java | 6 - .../models/dataservice/equation/Equation.java | 4 - .../dataservice/model/ModelConfiguration.java | 2 - .../notebooksession/NotebookSession.java | 5 - .../models/dataservice/project/Project.java | 7 - .../dataservice/simulation/Simulation.java | 9 +- .../models/dataservice/workflow/Workflow.java | 3 - .../V4__Change_description_to_text.sql | 6 + .../dataservice/ArtifactControllerTests.java | 22 +-- .../dataservice/AssetControllerTests.java | 8 +- .../dataservice/DatasetControllerTests.java | 44 +++--- .../dataservice/DocumentControllerTests.java | 38 ++--- .../dataservice/EquationControllerTests.java | 12 +- .../ModelConfigurationControllerTests.java | 34 ++--- .../NotebookSessionControllerTests.java | 12 +- .../dataservice/ProjectControllerTests.java | 20 +-- .../dataservice/TDSCodeControllerTests.java | 32 ++--- .../knowledge/KnowledgeControllerTests.java | 135 +++++++++--------- .../service/ExtractionServiceTests.java | 26 ++-- .../service/data/WorkflowServiceTests.java | 2 +- 26 files changed, 211 insertions(+), 261 deletions(-) create mode 100644 packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql diff --git a/packages/client/hmi-client/src/types/Types.ts b/packages/client/hmi-client/src/types/Types.ts index 2e3c5df738..fab1e308fb 100644 --- a/packages/client/hmi-client/src/types/Types.ts +++ b/packages/client/hmi-client/src/types/Types.ts @@ -25,6 +25,7 @@ export interface ClientLog { export interface TerariumAsset { id?: string; name?: string; + description?: string; createdOn?: Date; updatedOn?: Date; deletedOn?: Date; @@ -69,9 +70,7 @@ export interface GithubRepo { } export interface Artifact extends TerariumAsset { - name: string; userId: string; - description?: string; fileNames: string[]; metadata?: any; concepts?: OntologyConcept[]; @@ -122,8 +121,6 @@ export interface ResponseSuccess { } export interface Code extends TerariumAsset { - name: string; - description: string; files?: { [index: string]: CodeFile }; repoUrl?: string; metadata?: { [index: string]: string }; @@ -141,7 +138,6 @@ export interface Dynamics { } export interface ActiveConcept extends TerariumAsset { - name: string; curie: string; } @@ -158,10 +154,8 @@ export interface OntologyConcept { } export interface Dataset extends TerariumAsset { - name: string; userId?: string; esgfId?: string; - description?: string; dataSourceDate?: Date; fileNames?: string[]; datasetUrl?: string; @@ -195,7 +189,6 @@ export interface AddDocumentAssetFromXDDResponse { } export interface DocumentAsset extends TerariumAsset { - description?: string; userId?: string; fileNames?: string[]; documentUrl?: string; @@ -236,8 +229,6 @@ export interface Model extends TerariumAssetThatSupportsAdditionalProperties { } export interface ModelConfiguration extends TerariumAssetThatSupportsAdditionalProperties { - name: string; - description?: string; configuration: Model; model_id: string; } @@ -407,8 +398,6 @@ export interface DecapodesTerm { } export interface NotebookSession extends TerariumAsset { - name: string; - description?: string; data: any; } @@ -418,11 +407,9 @@ export interface PetriNetModel { } export interface Project extends TerariumAsset { - name: string; userId: string; userName?: string; authors?: string[]; - description?: string; overviewContent?: any; projectAssets: ProjectAsset[]; metadata?: { [index: string]: string }; @@ -504,7 +491,6 @@ export interface RegNetVertex { export interface Simulation extends TerariumAsset { executionPayload: any; - description?: string; resultFiles?: string[]; type: SimulationType; status: ProgressState; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java index 3f444deab3..636f5f7582 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java @@ -28,8 +28,15 @@ public abstract class TerariumAsset implements Serializable { private UUID id = UUID.randomUUID(); @TSOptional + @Column(length = 255) + @Schema(defaultValue = "Default Name") private String name; + @TSOptional + @Schema(defaultValue = "Default Description") + @Column(columnDefinition = "text") + private String description; + @TSOptional @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Column(columnDefinition = "TIMESTAMP WITH TIME ZONE") @@ -78,6 +85,7 @@ public TerariumAsset clone() { protected TerariumAsset cloneSuperFields(final TerariumAsset asset) { asset.id = UUID.randomUUID(); // ensure we create a new id asset.name = name; + asset.description = description; asset.createdOn = this.createdOn != null ? new Timestamp(this.createdOn.getTime()) : null; asset.updatedOn = this.updatedOn != null ? new Timestamp(this.updatedOn.getTime()) : null; asset.deletedOn = this.deletedOn != null ? new Timestamp(this.deletedOn.getTime()) : null; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/Artifact.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/Artifact.java index 74ca51bf26..db5b6a871c 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/Artifact.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/Artifact.java @@ -29,13 +29,6 @@ public class Artifact extends TerariumAsset { /* UserId of who created this asset */ private String userId; - /* The name of the artifact. */ - private String name; - - /* A description of the artifact. */ - @TSOptional - private String description; - /* The name of the file(s) in this artifact */ @JsonAlias("file_names") private List fileNames; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/code/Code.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/code/Code.java index bde50ceec8..9b45087da3 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/code/Code.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/code/Code.java @@ -21,12 +21,6 @@ public class Code extends TerariumAsset { @Serial private static final long serialVersionUID = 3041175096070970227L; /* The name of the code. */ - @Schema(defaultValue = "Default Name") - private String name; - - /* The description of the code. */ - @Schema(defaultValue = "Default Description") - private String description; /* Files that contain dynamics */ @TSOptional diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java index 370f4f8235..c2dfc21530 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java @@ -22,5 +22,4 @@ public class ActiveConcept extends TerariumAsset { @Column(unique = true) private String curie; - private String name; } diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/dataset/Dataset.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/dataset/Dataset.java index 1a8d199b8b..a3b53e1ae7 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/dataset/Dataset.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/dataset/Dataset.java @@ -30,13 +30,6 @@ public class Dataset extends TerariumAsset { @TSOptional private String esgfId; - /** Name of the dataset */ - private String name; - - /** (Optional) textual description of the dataset */ - @TSOptional - private String description; - /** (Optional) data source date */ @TSOptional @JsonAlias("data_source_date") diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/document/DocumentAsset.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/document/DocumentAsset.java index 91478179bf..e386bd071c 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/document/DocumentAsset.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/document/DocumentAsset.java @@ -24,12 +24,6 @@ public class DocumentAsset extends TerariumAsset { @Serial private static final long serialVersionUID = -8425680186002783351L; - @TSOptional - private String name; - - @TSOptional - private String description; - @TSOptional private String userId; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/equation/Equation.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/equation/Equation.java index 6eba279cfe..2a118a1264 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/equation/Equation.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/equation/Equation.java @@ -24,10 +24,6 @@ public class Equation extends TerariumAsset { @TSOptional private String userId; - /** (Optional) Display/human name for the equation * */ - @TSOptional - private String name; - /** The type of equation (mathml or latex) * */ @JsonAlias("equation_type") private EquationType equationType; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/model/ModelConfiguration.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/model/ModelConfiguration.java index 242ba9c9cc..dfe9a9f4b3 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/model/ModelConfiguration.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/model/ModelConfiguration.java @@ -19,8 +19,6 @@ public class ModelConfiguration extends TerariumAssetThatSupportsAdditionalPrope @Serial private static final long serialVersionUID = -4109896135386019667L; - private String name; - @TSOptional private String description; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java index 24a4f6589f..6b721faaee 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java @@ -18,10 +18,5 @@ public class NotebookSession extends TerariumAsset { @Serial private static final long serialVersionUID = 9176019416379347233L; - private String name; - - @TSOptional - private String description; - private JsonNode data; } diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/project/Project.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/project/Project.java index 12abd1fb25..0f805696c4 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/project/Project.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/project/Project.java @@ -31,9 +31,6 @@ public class Project extends TerariumAsset { @Serial private static final long serialVersionUID = -241733670076432802L; - @Schema(defaultValue = "My New Project") - private String name; - private String userId; @TSOptional @@ -46,10 +43,6 @@ public class Project extends TerariumAsset { @Schema(accessMode = Schema.AccessMode.READ_ONLY) private List authors; - @TSOptional - @Schema(defaultValue = "My Project Description") - private String description; - @TSOptional @Schema(defaultValue = "My Project Overview") @Lob diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/simulation/Simulation.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/simulation/Simulation.java index 6028815b6d..c01f5744e6 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/simulation/Simulation.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/simulation/Simulation.java @@ -31,13 +31,9 @@ public class Simulation extends TerariumAsset { @Column(columnDefinition = "text") private JsonNode executionPayload; - @TSOptional - @Column(length = 1000) - private String description; - @JsonAlias("result_files") @TSOptional - @Column(length = 1000) + @Column(length = 1024) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @ElementCollection private List resultFiles; @@ -73,6 +69,7 @@ public class Simulation extends TerariumAsset { @JsonAlias("user_id") @TSOptional + @Column(length = 255) private String userId; @JsonAlias("project_id") @@ -85,8 +82,6 @@ public Simulation clone() { cloneSuperFields(clone); - clone.setDescription(this.description); - clone.setResultFiles(new ArrayList<>(this.resultFiles)); clone.setType(SimulationType.valueOf(this.type.name())); clone.setStatus(ProgressState.valueOf(this.status.name())); diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/workflow/Workflow.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/workflow/Workflow.java index fdad4a98e0..b252a68923 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/workflow/Workflow.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/workflow/Workflow.java @@ -25,8 +25,6 @@ public class Workflow extends TerariumAsset { @Serial private static final long serialVersionUID = -1565930053830366145L; - private String description; - private Transform transform; @Convert(converter = ObjectConverter.class) @@ -43,7 +41,6 @@ public Workflow clone() { cloneSuperFields(clone); - clone.description = this.description; if (this.transform != null) { clone.transform = new Transform() .setX(this.transform.getX()) diff --git a/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql b/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql new file mode 100644 index 0000000000..85a155af56 --- /dev/null +++ b/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql @@ -0,0 +1,6 @@ +BEGIN; +ALTER TABLE simulation ALTER COLUMN result_files TYPE VARCHAR(1024)[]; +ALTER TABLE simulation ALTER COLUMN description TYPE text; +ALTER TABLE workflow ALTER COLUMN description TYPE text; +ALTER TABLE project ALTER COLUMN description TYPE text; +COMMIT; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java index 0001ba4ef7..bd27d1d5e4 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java @@ -50,7 +50,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateArtifact() throws Exception { - final Artifact artifact = new Artifact().setName("test-artifact-name").setDescription("my description"); + final Artifact artifact = (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/artifacts") .with(csrf()) @@ -63,8 +63,8 @@ public void testItCanCreateArtifact() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetArtifact() throws Exception { - final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + final Artifact artifact = artifactService.createAsset((Artifact) + new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/artifacts/" + artifact.getId()) .with(csrf())) @@ -75,9 +75,9 @@ public void testItCanGetArtifact() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetArtifacts() throws Exception { - artifactService.createAsset(new Artifact().setName("test-artifact-name").setDescription("my description")); - artifactService.createAsset(new Artifact().setName("test-artifact-name").setDescription("my description")); - artifactService.createAsset(new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/artifacts").with(csrf())) .andExpect(status().isOk()) @@ -89,7 +89,7 @@ public void testItCanGetArtifacts() throws Exception { public void testItCanDeleteArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/artifacts/" + artifact.getId()) .with(csrf())) @@ -103,7 +103,7 @@ public void testItCanDeleteArtifact() throws Exception { public void testItCanUploadArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -131,7 +131,7 @@ public void testItCanUploadArtifact() throws Exception { public void testItCanUploadArtifactFromGithub() throws Exception { final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/artifacts/" + artifact.getId() + "/upload-artifact-from-github") .with(csrf()) @@ -147,7 +147,7 @@ public void testItCanUploadArtifactFromGithub() throws Exception { public void testItCanDownloadArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadArtifact test"; @@ -188,7 +188,7 @@ public void testItCanDownloadArtifact() throws Exception { public void testItCanDownloadArtifactAsText() throws Exception { final Artifact artifact = artifactService.createAsset( - new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadArtifact test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java index acbe41ab04..34b75a82dd 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java @@ -137,9 +137,9 @@ public void testItCanVerifyAssetNameAvailabilityInProjects() throws Exception { */ @BeforeEach public void setUpScenario() throws Exception { - project = projectService.createProject(new Project().setName("test-proj-1")); + project = projectService.createProject((Project) new Project().setName("test-proj-1")); - final DocumentAsset documentAsset = documentAssetService.createAsset( + final DocumentAsset documentAsset = documentAssetService.createAsset( (DocumentAsset) new DocumentAsset().setName(TEST_ASSET_NAME_1).setDescription("my description")); final ProjectAsset projectAsset = new ProjectAsset() @@ -154,9 +154,9 @@ public void setUpScenario() throws Exception { .content(objectMapper.writeValueAsString(projectAsset))) .andExpect(status().isCreated()); - project2 = projectService.createProject(new Project().setName("test-proj-2")); + project2 = projectService.createProject((Project)new Project().setName("test-proj-2")); - final DocumentAsset documentAsset2 = documentAssetService.createAsset( + final DocumentAsset documentAsset2 = documentAssetService.createAsset( (DocumentAsset) new DocumentAsset().setName(TEST_ASSET_NAME_2).setDescription("my description")); final ProjectAsset projectAsset2 = new ProjectAsset() diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java index 216327cdf6..825338855a 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java @@ -61,7 +61,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateDataset() throws Exception { - final Dataset dataset = new Dataset().setName("test-dataset-name").setDescription("my description"); + final Dataset dataset = (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/datasets") .with(csrf()) @@ -74,8 +74,8 @@ public void testItCanCreateDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDataset() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId()) .with(csrf())) @@ -86,11 +86,11 @@ public void testItCanGetDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDatasets() throws Exception { - datasetService.createAsset(new Dataset().setName("test-dataset-name0").setDescription("my description")); + datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name0").setDescription("my description")); - datasetService.createAsset(new Dataset().setName("test-dataset-name1").setDescription("my description")); + datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name1").setDescription("my description")); - datasetService.createAsset(new Dataset().setName("test-dataset-name2").setDescription("my description")); + datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name2").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/datasets").with(csrf())) .andExpect(status().isOk()) @@ -101,8 +101,8 @@ public void testItCanGetDatasets() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteDataset() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/datasets/" + dataset.getId()) .with(csrf())) @@ -115,8 +115,8 @@ public void testItCanDeleteDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDatasetCSV() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -145,8 +145,8 @@ public void testItCanUploadDatasetCSV() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDatasetFromGithub() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/datasets/" + dataset.getId() + "/upload-csv-from-github") .with(csrf()) @@ -161,8 +161,8 @@ public void testItCanUploadDatasetFromGithub() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDatasetCSV() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -202,8 +202,8 @@ public void testItCanDownloadDatasetCSV() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDataset() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "This is my small test dataset\n"; @@ -232,8 +232,8 @@ public void testItCanUploadDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDataset() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -272,8 +272,8 @@ public void testItCanDownloadDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetUploadUrl() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-dataset-name").setDescription("my description")); // Perform the multipart file upload request final MvcResult res = mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId() + "/upload-url") @@ -303,8 +303,8 @@ public void testItCanGetUploadUrl() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDownloadUrl() throws Exception { - final Dataset dataset = datasetService.createAsset( - new Dataset().setName("test-document-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset((Dataset) + new Dataset().setName("test-document-name").setDescription("my description")); // Perform the multipart file upload request MvcResult res = mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId() + "/upload-url") diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java index 32e764d333..5f3faed194 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java @@ -50,7 +50,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateDocument() throws Exception { - final DocumentAsset documentAsset = + final DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset().setName("test-document-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/document-asset") @@ -64,8 +64,8 @@ public void testItCanCreateDocument() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDocument() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/document-asset/" + documentAsset.getId()) .with(csrf())) @@ -76,14 +76,14 @@ public void testItCanGetDocument() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDocuments() throws Exception { - documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); - documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); - documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/document-asset").with(csrf())) .andExpect(status().isOk()) @@ -94,8 +94,8 @@ public void testItCanGetDocuments() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteDocument() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/document-asset/" + documentAsset.getId()) .with(csrf())) @@ -109,8 +109,8 @@ public void testItCanDeleteDocument() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDocument() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -138,8 +138,8 @@ public void testItCanUploadDocument() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDocumentFromGithub() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put( "/document-asset/" + documentAsset.getId() + "/upload-document-from-github") @@ -155,8 +155,8 @@ public void testItCanUploadDocumentFromGithub() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDocument() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadDocument test"; @@ -197,8 +197,8 @@ public void testItCanDownloadDocument() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDocumentAsText() throws Exception { - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadDocument test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java index d335930b5d..57f80d82c0 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java @@ -47,7 +47,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateEquation() throws Exception { - final Equation equation = new Equation().setName("test-equation-name"); + final Equation equation = (Equation)new Equation().setName("test-equation-name"); mockMvc.perform(MockMvcRequestBuilders.post("/equations") .with(csrf()) @@ -60,7 +60,7 @@ public void testItCanCreateEquation() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetEquation() throws Exception { - final Equation equation = equationService.createAsset(new Equation().setName("test-equation-name")); + final Equation equation = equationService.createAsset((Equation)new Equation().setName("test-equation-name")); mockMvc.perform(MockMvcRequestBuilders.get("/equations/" + equation.getId()) .with(csrf())) @@ -71,9 +71,9 @@ public void testItCanGetEquation() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetEquations() throws Exception { - equationService.createAsset(new Equation().setName("test-equation-name")); - equationService.createAsset(new Equation().setName("test-equation-name")); - equationService.createAsset(new Equation().setName("test-equation-name")); + equationService.createAsset((Equation) new Equation().setName("test-equation-name")); + equationService.createAsset((Equation) new Equation().setName("test-equation-name")); + equationService.createAsset((Equation) new Equation().setName("test-equation-name")); mockMvc.perform(MockMvcRequestBuilders.get("/equations").with(csrf())) .andExpect(status().isOk()) @@ -84,7 +84,7 @@ public void testItCanGetEquations() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteEquation() throws Exception { - final Equation equation = equationService.createAsset(new Equation().setName("test-equation-name")); + final Equation equation = equationService.createAsset((Equation) new Equation().setName("test-equation-name")); mockMvc.perform(MockMvcRequestBuilders.delete("/equations/" + equation.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java index c8667e8e4f..b37326affc 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java @@ -49,11 +49,11 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanGetModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset(new ModelConfiguration() - .setName("test-framework") + final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset((ModelConfiguration)new ModelConfiguration() .setModelId(UUID.randomUUID()) - .setDescription("test-desc") - .setConfiguration(new Model())); + .setConfiguration(new Model()) + .setName("test-framework") + .setDescription("test-desc")); mockMvc.perform(MockMvcRequestBuilders.get("/model-configurations/" + modelConfiguration.getId()) .with(csrf())) @@ -64,11 +64,11 @@ public void testItCanGetModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanCreateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = new ModelConfiguration() - .setName("test-framework") + final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) .setDescription("test-desc") - .setConfiguration(new Model()); + .setName("test-framework"); mockMvc.perform(MockMvcRequestBuilders.post("/model-configurations") .with(csrf()) @@ -81,11 +81,11 @@ public void testItCanCreateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUpdateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset(new ModelConfiguration() - .setName("test-framework") - .setModelId(UUID.randomUUID()) - .setDescription("test-desc") - .setConfiguration(new Model())); + final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework"); mockMvc.perform(MockMvcRequestBuilders.put("/model-configurations/" + modelConfiguration.getId()) .with(csrf()) @@ -98,11 +98,11 @@ public void testItCanUpdateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset(new ModelConfiguration() - .setName("test-framework") - .setModelId(UUID.randomUUID()) - .setDescription("test-desc") - .setConfiguration(new Model())); + final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework"); mockMvc.perform(MockMvcRequestBuilders.delete("/model-configurations/" + modelConfiguration.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java index dbc3c92d5e..b92bae4b01 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java @@ -47,7 +47,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateNotebookSession() throws Exception { - final NotebookSession notebookSession = new NotebookSession().setName("test-notebook-name"); + final NotebookSession notebookSession = (NotebookSession) new NotebookSession().setName("test-notebook-name"); mockMvc.perform(MockMvcRequestBuilders.post("/sessions") .with(csrf()) @@ -61,7 +61,7 @@ public void testItCanCreateNotebookSession() throws Exception { public void testItCanGetNotebookSession() throws Exception { final NotebookSession notebookSession = - notebookSessionService.createAsset(new NotebookSession().setName("test-notebook-name")); + notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); mockMvc.perform(MockMvcRequestBuilders.get("/sessions/" + notebookSession.getId()) .with(csrf())) @@ -72,9 +72,9 @@ public void testItCanGetNotebookSession() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetNotebookSessions() throws Exception { - notebookSessionService.createAsset(new NotebookSession().setName("test-notebook-name")); - notebookSessionService.createAsset(new NotebookSession().setName("test-notebook-name")); - notebookSessionService.createAsset(new NotebookSession().setName("test-notebook-name")); + notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); + notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); + notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); mockMvc.perform(MockMvcRequestBuilders.get("/sessions").with(csrf())) .andExpect(status().isOk()) @@ -86,7 +86,7 @@ public void testItCanGetNotebookSessions() throws Exception { public void testItCanDeleteNotebookSession() throws Exception { final NotebookSession notebookSession = - notebookSessionService.createAsset(new NotebookSession().setName("test-notebook-name")); + notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); mockMvc.perform(MockMvcRequestBuilders.delete("/sessions/" + notebookSession.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java index 88be11def3..221d6631c4 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java @@ -60,7 +60,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateProject() throws Exception { - final Project project = new Project().setName("test-name"); + final Project project = (Project) new Project().setName("test-name"); mockMvc.perform(MockMvcRequestBuilders.post("/projects") .with(csrf()) @@ -73,7 +73,7 @@ public void testItCanCreateProject() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetProject() throws Exception { - final Project project = projectService.createProject(new Project().setName("test-name")); + final Project project = projectService.createProject((Project) new Project().setName("test-name")); mockMvc.perform(MockMvcRequestBuilders.get("/projects/" + project.getId()) .with(csrf())) @@ -84,7 +84,7 @@ public void testItCanGetProject() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUpdateProject() throws Exception { - final Project project = projectService.createProject(new Project().setName("test-name")); + final Project project = projectService.createProject((Project) new Project().setName("test-name")); mockMvc.perform(MockMvcRequestBuilders.put("/projects/" + project.getId()) .with(csrf()) @@ -97,7 +97,7 @@ public void testItCanUpdateProject() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteProject() throws Exception { - final Project project = projectService.createProject(new Project().setName("test-name")); + final Project project = projectService.createProject((Project) new Project().setName("test-name")); mockMvc.perform(MockMvcRequestBuilders.delete("/projects/" + project.getId()) .with(csrf())) @@ -110,10 +110,10 @@ public void testItCanDeleteProject() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanCreateProjectAsset() throws Exception { - final Project project = projectService.createProject(new Project().setName("test-name")); + final Project project = projectService.createProject((Project) new Project().setName("test-name")); - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); final ProjectAsset projectAsset = new ProjectAsset() .setAssetId(documentAsset.getId()) @@ -143,10 +143,10 @@ public void testItCanCreateProjectAsset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteProjectAsset() throws Exception { - final Project project = projectService.createProject(new Project().setName("test-name")); + final Project project = projectService.createProject((Project) new Project().setName("test-name")); - final DocumentAsset documentAsset = documentAssetService.createAsset( - new DocumentAsset().setName("test-document-name").setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) + new DocumentAsset().setName("test-document-name").setDescription("my description")); projectAssetService.createProjectAsset(project, AssetType.DOCUMENT, documentAsset); diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java index 83e4fa3a20..20e8df31fc 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java @@ -50,7 +50,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateCode() throws Exception { - final Code codeAsset = new Code().setName("test-code-name").setDescription("my description"); + final Code codeAsset = (Code) new Code().setName("test-code-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/code-asset") .with(csrf()) @@ -63,8 +63,8 @@ public void testItCanCreateCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/code-asset/" + codeAsset.getId()) .with(csrf())) @@ -75,11 +75,11 @@ public void testItCanGetCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetCodes() throws Exception { - codeAssetService.createAsset(new Code().setName("test-code-name").setDescription("my description")); + codeAssetService.createAsset((Code) new Code().setName("test-code-name").setDescription("my description")); - codeAssetService.createAsset(new Code().setName("test-code-name").setDescription("my description")); + codeAssetService.createAsset((Code) new Code().setName("test-code-name").setDescription("my description")); - codeAssetService.createAsset(new Code().setName("test-code-name").setDescription("my description")); + codeAssetService.createAsset((Code) new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/code-asset").with(csrf())) .andExpect(status().isOk()) @@ -90,8 +90,8 @@ public void testItCanGetCodes() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/code-asset/" + codeAsset.getId()) .with(csrf())) @@ -104,8 +104,8 @@ public void testItCanDeleteCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -132,8 +132,8 @@ public void testItCanUploadCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCodeFromGithub() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/code-asset/" + codeAsset.getId() + "/upload-code-from-github") .with(csrf()) @@ -148,8 +148,8 @@ public void testItCanUploadCodeFromGithub() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCodeFromGithubRepo() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/code-asset/" + codeAsset.getId() + "/upload-code-from-github-repo") .with(csrf()) @@ -163,8 +163,8 @@ public void testItCanUploadCodeFromGithubRepo() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadCodeAsText() throws Exception { - final Code codeAsset = codeAssetService.createAsset( - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset((Code) + new Code().setName("test-code-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadCode test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java index f3098524b0..a18a1abd38 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java @@ -256,10 +256,10 @@ public void base64EquationsToLatexTests() throws Exception { @WithUserDetails(MockUser.URSULA) public void variableExtractionTests() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") - .setDescription("my description") - .setText("x = 0. y = 1. I = Infected population."); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -275,10 +275,11 @@ public void variableExtractionTests() throws Exception { @WithUserDetails(MockUser.URSULA) public void variableExtractionWithModelTests() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") .setDescription("my description") - .setText("x = 0. y = 1. I = Infected population."); + ; documentAsset = documentAssetService.createAsset(documentAsset); @@ -301,10 +302,10 @@ public void variableExtractionWithModelTests() throws Exception { @WithUserDetails(MockUser.URSULA) public void linkAmrTests() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") - .setDescription("my description") - .setText("x = 0. y = 1. I = Infected population."); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -340,10 +341,10 @@ public void cosmosPdfExtraction() throws Exception { final HttpEntity pdfFileEntity = new ByteArrayEntity(content, ContentType.create("application/pdf")); - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset)new DocumentAsset() + .setFileNames(List.of("paper.pdf")) .setName("test-pdf-name") - .setDescription("my description") - .setFileNames(List.of("paper.pdf")); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -361,30 +362,30 @@ public void cosmosPdfExtraction() throws Exception { @WithUserDetails(MockUser.URSULA) public void profileModel() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText( + """ + In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading + of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a + theoretical framework to investigate its spread within a community. Here, the model is based upon the + well-known susceptible-infected-removed (SIR) model with the difference that a total population is not + defined or kept constant per se and the number of susceptible individuals does not decline monotonically. + To the contrary, as we show herein, it can be increased in surge periods! In particular, we investigate + the time evolution of different populations and monitor diverse significant parameters for the spread + of the disease in various communities, represented by China, South Korea, India, Australia, USA, Italy + and the state of Texas in the USA. The SIR model can provide us with insights and predictions of the + spread of the virus in communities that the recorded data alone cannot. Our work shows the importance + of modelling the spread of COVID-19 by the SIR model that we propose here, as it can help to assess + the impact of the disease by offering valuable predictions. Our analysis takes into account data from + January to June, 2020, the period that contains the data before and during the implementation of strict + and control measures. We propose predictions on various parameters related to the spread of COVID-19 + and on the number of susceptible, infected and removed populations until September 2020. By comparing + the recorded data with the data from our modelling approaches, we deduce that the spread of COVID- + 19 can be under control in all communities considered, if proper restrictions and strong policies are + implemented to control the infection rates early from the spread of the disease. + """) .setName("test-pdf-name") - .setDescription("my description") - .setText( - """ - In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading - of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a - theoretical framework to investigate its spread within a community. Here, the model is based upon the - well-known susceptible-infected-removed (SIR) model with the difference that a total population is not - defined or kept constant per se and the number of susceptible individuals does not decline monotonically. - To the contrary, as we show herein, it can be increased in surge periods! In particular, we investigate - the time evolution of different populations and monitor diverse significant parameters for the spread - of the disease in various communities, represented by China, South Korea, India, Australia, USA, Italy - and the state of Texas in the USA. The SIR model can provide us with insights and predictions of the - spread of the virus in communities that the recorded data alone cannot. Our work shows the importance - of modelling the spread of COVID-19 by the SIR model that we propose here, as it can help to assess - the impact of the disease by offering valuable predictions. Our analysis takes into account data from - January to June, 2020, the period that contains the data before and during the implementation of strict - and control measures. We propose predictions on various parameters related to the spread of COVID-19 - and on the number of susceptible, infected and removed populations until September 2020. By comparing - the recorded data with the data from our modelling approaches, we deduce that the spread of COVID- - 19 can be under control in all communities considered, if proper restrictions and strong policies are - implemented to control the infection rates early from the spread of the disease. - """); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -412,7 +413,7 @@ public void profileDataset() throws Exception { final ClassPathResource resource = new ClassPathResource("knowledge/dataset.csv"); final byte[] content = Files.readAllBytes(resource.getFile().toPath()); - Dataset dataset = datasetService.createAsset( + Dataset dataset = datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); // Create a MockMultipartFile object @@ -435,30 +436,30 @@ public void profileDataset() throws Exception { })) .andExpect(status().isOk()); - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText( + """ + In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading + of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a + theoretical framework to investigate its spread within a community. Here, the model is based upon the + well-known susceptible-infected-removed (SIR) model with the difference that a total population is not + defined or kept constant per se and the number of susceptible individuals does not decline monotonically. + To the contrary, as we show herein, it can be increased in surge periods! In particular, we investigate + the time evolution of different populations and monitor diverse significant parameters for the spread + of the disease in various communities, represented by China, South Korea, India, Australia, USA, Italy + and the state of Texas in the USA. The SIR model can provide us with insights and predictions of the + spread of the virus in communities that the recorded data alone cannot. Our work shows the importance + of modelling the spread of COVID-19 by the SIR model that we propose here, as it can help to assess + the impact of the disease by offering valuable predictions. Our analysis takes into account data from + January to June, 2020, the period that contains the data before and during the implementation of strict + and control measures. We propose predictions on various parameters related to the spread of COVID-19 + and on the number of susceptible, infected and removed populations until September 2020. By comparing + the recorded data with the data from our modelling approaches, we deduce that the spread of COVID- + 19 can be under control in all communities considered, if proper restrictions and strong policies are + implemented to control the infection rates early from the spread of the disease. + """) .setName("test-pdf-name") - .setDescription("my description") - .setText( - """ - In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading - of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a - theoretical framework to investigate its spread within a community. Here, the model is based upon the - well-known susceptible-infected-removed (SIR) model with the difference that a total population is not - defined or kept constant per se and the number of susceptible individuals does not decline monotonically. - To the contrary, as we show herein, it can be increased in surge periods! In particular, we investigate - the time evolution of different populations and monitor diverse significant parameters for the spread - of the disease in various communities, represented by China, South Korea, India, Australia, USA, Italy - and the state of Texas in the USA. The SIR model can provide us with insights and predictions of the - spread of the virus in communities that the recorded data alone cannot. Our work shows the importance - of modelling the spread of COVID-19 by the SIR model that we propose here, as it can help to assess - the impact of the disease by offering valuable predictions. Our analysis takes into account data from - January to June, 2020, the period that contains the data before and during the implementation of strict - and control measures. We propose predictions on various parameters related to the spread of COVID-19 - and on the number of susceptible, infected and removed populations until September 2020. By comparing - the recorded data with the data from our modelling approaches, we deduce that the spread of COVID- - 19 can be under control in all communities considered, if proper restrictions and strong policies are - implemented to control the infection rates early from the spread of the disease. - """); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -488,10 +489,10 @@ public void codeToAmrTest() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset(new Code() + final Code code = codeService.createAsset((Code) new Code() + .setFiles(files) .setName("test-code-name") - .setDescription("my description") - .setFiles(files)); + .setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); @@ -522,10 +523,10 @@ public void codeToAmrTestLLM() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset(new Code() + final Code code = codeService.createAsset((Code) new Code() + .setFiles(files) .setName("test-code-name") - .setDescription("my description") - .setFiles(files)); + .setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); @@ -557,10 +558,10 @@ public void codeToAmrTestDynamicsOnly() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset(new Code() + final Code code = codeService.createAsset((Code)new Code() + .setFiles(files) .setName("test-code-name") - .setDescription("my description") - .setFiles(files)); + .setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java index 2a61f54396..b495254028 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java @@ -58,10 +58,10 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void variableExtractionTests() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") - .setDescription("my description") - .setText("x = 0. y = 1. I = Infected population."); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -77,10 +77,11 @@ public void variableExtractionWithModelTests() throws Exception { final ClassPathResource resource1 = new ClassPathResource("knowledge/extraction_text.txt"); final byte[] content1 = Files.readAllBytes(resource1.getFile().toPath()); - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + + .setText(new String(content1)) .setName("test-document-name") - .setDescription("my description") - .setText(new String(content1)); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -99,10 +100,11 @@ public void variableExtractionWithModelTests() throws Exception { @WithUserDetails(MockUser.URSULA) public void linkAmrTests() throws Exception { - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") - .setDescription("my description") - .setText("x = 0. y = 1. I = Infected population."); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -128,10 +130,10 @@ public void cosmosPdfExtraction() throws Exception { final HttpEntity pdfFileEntity = new ByteArrayEntity(content, ContentType.create("application/pdf")); - DocumentAsset documentAsset = new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() + .setFileNames(List.of("paper.pdf")) .setName("test-pdf-name") - .setDescription("my description") - .setFileNames(List.of("paper.pdf")); + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/WorkflowServiceTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/WorkflowServiceTests.java index 85180cd941..32a60f76f1 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/WorkflowServiceTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/WorkflowServiceTests.java @@ -52,11 +52,11 @@ static Workflow createWorkflow() throws Exception { final WorkflowEdge cd = new WorkflowEdge().setSource(c.getId()).setTarget(d.getId()); return (Workflow) new Workflow() - .setDescription("test-workflow-description-0") .setTransform(new Transform().setX(1).setY(2).setK(3)) .setNodes(List.of(a, b, c, d)) .setEdges(List.of(ab, bc, cd)) .setPublicAsset(true) + .setDescription("test-workflow-description-0") .setName("test-workflow-name-0"); } From 69ab0b2ff1ee1278e4dc52219bd5dea639d51bc1 Mon Sep 17 00:00:00 2001 From: dvince2 Date: Mon, 29 Apr 2024 18:31:22 +0000 Subject: [PATCH 2/6] chore: lint server codebase --- .../dataservice/concept/ActiveConcept.java | 1 - .../notebooksession/NotebookSession.java | 1 - .../dataservice/ArtifactControllerTests.java | 26 +++++----- .../dataservice/AssetControllerTests.java | 10 ++-- .../dataservice/DatasetControllerTests.java | 48 ++++++++++--------- .../dataservice/DocumentControllerTests.java | 18 +++---- .../dataservice/EquationControllerTests.java | 4 +- .../ModelConfigurationControllerTests.java | 33 ++++++------- .../NotebookSessionControllerTests.java | 8 ++-- .../dataservice/ProjectControllerTests.java | 4 +- .../dataservice/TDSCodeControllerTests.java | 24 +++++----- .../knowledge/KnowledgeControllerTests.java | 35 ++++++-------- .../service/ExtractionServiceTests.java | 10 ++-- 13 files changed, 110 insertions(+), 112 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java index c2dfc21530..2a244369d5 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/concept/ActiveConcept.java @@ -21,5 +21,4 @@ public class ActiveConcept extends TerariumAsset { @Column(unique = true) private String curie; - } diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java index 6b721faaee..368369a38a 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/notebooksession/NotebookSession.java @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import software.uncharted.terarium.hmiserver.annotations.TSModel; -import software.uncharted.terarium.hmiserver.annotations.TSOptional; import software.uncharted.terarium.hmiserver.models.TerariumAsset; @EqualsAndHashCode(callSuper = true) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java index bd27d1d5e4..1a3b0a3038 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ArtifactControllerTests.java @@ -50,7 +50,8 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateArtifact() throws Exception { - final Artifact artifact = (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description"); + final Artifact artifact = + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/artifacts") .with(csrf()) @@ -63,8 +64,8 @@ public void testItCanCreateArtifact() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetArtifact() throws Exception { - final Artifact artifact = artifactService.createAsset((Artifact) - new Artifact().setName("test-artifact-name").setDescription("my description")); + final Artifact artifact = artifactService.createAsset( + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/artifacts/" + artifact.getId()) .with(csrf())) @@ -75,9 +76,12 @@ public void testItCanGetArtifact() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetArtifacts() throws Exception { - artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); - artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); - artifactService.createAsset((Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset( + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset( + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + artifactService.createAsset( + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/artifacts").with(csrf())) .andExpect(status().isOk()) @@ -89,7 +93,7 @@ public void testItCanGetArtifacts() throws Exception { public void testItCanDeleteArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/artifacts/" + artifact.getId()) .with(csrf())) @@ -103,7 +107,7 @@ public void testItCanDeleteArtifact() throws Exception { public void testItCanUploadArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -131,7 +135,7 @@ public void testItCanUploadArtifact() throws Exception { public void testItCanUploadArtifactFromGithub() throws Exception { final Artifact artifact = artifactService.createAsset( - (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/artifacts/" + artifact.getId() + "/upload-artifact-from-github") .with(csrf()) @@ -147,7 +151,7 @@ public void testItCanUploadArtifactFromGithub() throws Exception { public void testItCanDownloadArtifact() throws Exception { final Artifact artifact = artifactService.createAsset( - (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadArtifact test"; @@ -188,7 +192,7 @@ public void testItCanDownloadArtifact() throws Exception { public void testItCanDownloadArtifactAsText() throws Exception { final Artifact artifact = artifactService.createAsset( - (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); + (Artifact) new Artifact().setName("test-artifact-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadArtifact test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java index 34b75a82dd..d47312d119 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/AssetControllerTests.java @@ -139,8 +139,8 @@ public void testItCanVerifyAssetNameAvailabilityInProjects() throws Exception { public void setUpScenario() throws Exception { project = projectService.createProject((Project) new Project().setName("test-proj-1")); - final DocumentAsset documentAsset = documentAssetService.createAsset( (DocumentAsset) - new DocumentAsset().setName(TEST_ASSET_NAME_1).setDescription("my description")); + final DocumentAsset documentAsset = documentAssetService.createAsset( + (DocumentAsset) new DocumentAsset().setName(TEST_ASSET_NAME_1).setDescription("my description")); final ProjectAsset projectAsset = new ProjectAsset() .setAssetId(documentAsset.getId()) @@ -154,10 +154,10 @@ public void setUpScenario() throws Exception { .content(objectMapper.writeValueAsString(projectAsset))) .andExpect(status().isCreated()); - project2 = projectService.createProject((Project)new Project().setName("test-proj-2")); + project2 = projectService.createProject((Project) new Project().setName("test-proj-2")); - final DocumentAsset documentAsset2 = documentAssetService.createAsset( (DocumentAsset) - new DocumentAsset().setName(TEST_ASSET_NAME_2).setDescription("my description")); + final DocumentAsset documentAsset2 = documentAssetService.createAsset( + (DocumentAsset) new DocumentAsset().setName(TEST_ASSET_NAME_2).setDescription("my description")); final ProjectAsset projectAsset2 = new ProjectAsset() .setAssetId(documentAsset.getId()) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java index 825338855a..51add8e8bf 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DatasetControllerTests.java @@ -61,7 +61,8 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateDataset() throws Exception { - final Dataset dataset = (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description"); + final Dataset dataset = + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description"); mockMvc.perform(MockMvcRequestBuilders.post("/datasets") .with(csrf()) @@ -74,8 +75,8 @@ public void testItCanCreateDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDataset() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId()) .with(csrf())) @@ -86,11 +87,14 @@ public void testItCanGetDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDatasets() throws Exception { - datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name0").setDescription("my description")); + datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name0").setDescription("my description")); - datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name1").setDescription("my description")); + datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name1").setDescription("my description")); - datasetService.createAsset((Dataset) new Dataset().setName("test-dataset-name2").setDescription("my description")); + datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name2").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/datasets").with(csrf())) .andExpect(status().isOk()) @@ -101,8 +105,8 @@ public void testItCanGetDatasets() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteDataset() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/datasets/" + dataset.getId()) .with(csrf())) @@ -115,8 +119,8 @@ public void testItCanDeleteDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDatasetCSV() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -145,8 +149,8 @@ public void testItCanUploadDatasetCSV() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDatasetFromGithub() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/datasets/" + dataset.getId() + "/upload-csv-from-github") .with(csrf()) @@ -161,8 +165,8 @@ public void testItCanUploadDatasetFromGithub() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDatasetCSV() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -202,8 +206,8 @@ public void testItCanDownloadDatasetCSV() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadDataset() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "This is my small test dataset\n"; @@ -232,8 +236,8 @@ public void testItCanUploadDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadDataset() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); final String content = "col0,col1,col2,col3\na,b,c,d\n"; @@ -272,8 +276,8 @@ public void testItCanDownloadDataset() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetUploadUrl() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); // Perform the multipart file upload request final MvcResult res = mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId() + "/upload-url") @@ -303,8 +307,8 @@ public void testItCanGetUploadUrl() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetDownloadUrl() throws Exception { - final Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-document-name").setDescription("my description")); + final Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-document-name").setDescription("my description")); // Perform the multipart file upload request MvcResult res = mockMvc.perform(MockMvcRequestBuilders.get("/datasets/" + dataset.getId() + "/upload-url") diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java index 5f3faed194..a99f9e3ee8 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/DocumentControllerTests.java @@ -65,7 +65,7 @@ public void testItCanCreateDocument() throws Exception { public void testItCanGetDocument() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/document-asset/" + documentAsset.getId()) .with(csrf())) @@ -77,13 +77,13 @@ public void testItCanGetDocument() throws Exception { public void testItCanGetDocuments() throws Exception { documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/document-asset").with(csrf())) .andExpect(status().isOk()) @@ -95,7 +95,7 @@ public void testItCanGetDocuments() throws Exception { public void testItCanDeleteDocument() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/document-asset/" + documentAsset.getId()) .with(csrf())) @@ -110,7 +110,7 @@ public void testItCanDeleteDocument() throws Exception { public void testItCanUploadDocument() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -139,7 +139,7 @@ public void testItCanUploadDocument() throws Exception { public void testItCanUploadDocumentFromGithub() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put( "/document-asset/" + documentAsset.getId() + "/upload-document-from-github") @@ -156,7 +156,7 @@ public void testItCanUploadDocumentFromGithub() throws Exception { public void testItCanDownloadDocument() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadDocument test"; @@ -198,7 +198,7 @@ public void testItCanDownloadDocument() throws Exception { public void testItCanDownloadDocumentAsText() throws Exception { final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadDocument test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java index 57f80d82c0..47795be29a 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/EquationControllerTests.java @@ -47,7 +47,7 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanCreateEquation() throws Exception { - final Equation equation = (Equation)new Equation().setName("test-equation-name"); + final Equation equation = (Equation) new Equation().setName("test-equation-name"); mockMvc.perform(MockMvcRequestBuilders.post("/equations") .with(csrf()) @@ -60,7 +60,7 @@ public void testItCanCreateEquation() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetEquation() throws Exception { - final Equation equation = equationService.createAsset((Equation)new Equation().setName("test-equation-name")); + final Equation equation = equationService.createAsset((Equation) new Equation().setName("test-equation-name")); mockMvc.perform(MockMvcRequestBuilders.get("/equations/" + equation.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java index b37326affc..274a3134b1 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java @@ -49,11 +49,12 @@ public void teardown() throws IOException { @WithUserDetails(MockUser.URSULA) public void testItCanGetModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset((ModelConfiguration)new ModelConfiguration() - .setModelId(UUID.randomUUID()) - .setConfiguration(new Model()) - .setName("test-framework") - .setDescription("test-desc")); + final ModelConfiguration modelConfiguration = + modelConfigurationService.createAsset((ModelConfiguration) new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setName("test-framework") + .setDescription("test-desc")); mockMvc.perform(MockMvcRequestBuilders.get("/model-configurations/" + modelConfiguration.getId()) .with(csrf())) @@ -64,7 +65,7 @@ public void testItCanGetModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanCreateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() + final ModelConfiguration modelConfiguration = (ModelConfiguration) new ModelConfiguration() .setModelId(UUID.randomUUID()) .setConfiguration(new Model()) .setDescription("test-desc") @@ -81,11 +82,11 @@ public void testItCanCreateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUpdateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() - .setModelId(UUID.randomUUID()) - .setConfiguration(new Model()) - .setDescription("test-desc") - .setName("test-framework"); + final ModelConfiguration modelConfiguration = (ModelConfiguration) new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework"); mockMvc.perform(MockMvcRequestBuilders.put("/model-configurations/" + modelConfiguration.getId()) .with(csrf()) @@ -98,11 +99,11 @@ public void testItCanUpdateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = (ModelConfiguration)new ModelConfiguration() - .setModelId(UUID.randomUUID()) - .setConfiguration(new Model()) - .setDescription("test-desc") - .setName("test-framework"); + final ModelConfiguration modelConfiguration = (ModelConfiguration) new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework"); mockMvc.perform(MockMvcRequestBuilders.delete("/model-configurations/" + modelConfiguration.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java index b92bae4b01..b6ee240ee8 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/NotebookSessionControllerTests.java @@ -60,8 +60,8 @@ public void testItCanCreateNotebookSession() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetNotebookSession() throws Exception { - final NotebookSession notebookSession = - notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); + final NotebookSession notebookSession = notebookSessionService.createAsset( + (NotebookSession) new NotebookSession().setName("test-notebook-name")); mockMvc.perform(MockMvcRequestBuilders.get("/sessions/" + notebookSession.getId()) .with(csrf())) @@ -85,8 +85,8 @@ public void testItCanGetNotebookSessions() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteNotebookSession() throws Exception { - final NotebookSession notebookSession = - notebookSessionService.createAsset((NotebookSession) new NotebookSession().setName("test-notebook-name")); + final NotebookSession notebookSession = notebookSessionService.createAsset( + (NotebookSession) new NotebookSession().setName("test-notebook-name")); mockMvc.perform(MockMvcRequestBuilders.delete("/sessions/" + notebookSession.getId()) .with(csrf())) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java index 221d6631c4..8ca53ffa28 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ProjectControllerTests.java @@ -113,7 +113,7 @@ public void testItCanCreateProjectAsset() throws Exception { final Project project = projectService.createProject((Project) new Project().setName("test-name")); final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); final ProjectAsset projectAsset = new ProjectAsset() .setAssetId(documentAsset.getId()) @@ -146,7 +146,7 @@ public void testItCanDeleteProjectAsset() throws Exception { final Project project = projectService.createProject((Project) new Project().setName("test-name")); final DocumentAsset documentAsset = documentAssetService.createAsset((DocumentAsset) - new DocumentAsset().setName("test-document-name").setDescription("my description")); + new DocumentAsset().setName("test-document-name").setDescription("my description")); projectAssetService.createProjectAsset(project, AssetType.DOCUMENT, documentAsset); diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java index 20e8df31fc..1d503179fc 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/TDSCodeControllerTests.java @@ -63,8 +63,8 @@ public void testItCanCreateCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanGetCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.get("/code-asset/" + codeAsset.getId()) .with(csrf())) @@ -90,8 +90,8 @@ public void testItCanGetCodes() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDeleteCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.delete("/code-asset/" + codeAsset.getId()) .with(csrf())) @@ -104,8 +104,8 @@ public void testItCanDeleteCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCode() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -132,8 +132,8 @@ public void testItCanUploadCode() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCodeFromGithub() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/code-asset/" + codeAsset.getId() + "/upload-code-from-github") .with(csrf()) @@ -148,8 +148,8 @@ public void testItCanUploadCodeFromGithub() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUploadCodeFromGithubRepo() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); mockMvc.perform(MockMvcRequestBuilders.put("/code-asset/" + codeAsset.getId() + "/upload-code-from-github-repo") .with(csrf()) @@ -163,8 +163,8 @@ public void testItCanUploadCodeFromGithubRepo() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanDownloadCodeAsText() throws Exception { - final Code codeAsset = codeAssetService.createAsset((Code) - new Code().setName("test-code-name").setDescription("my description")); + final Code codeAsset = codeAssetService.createAsset( + (Code) new Code().setName("test-code-name").setDescription("my description")); final String content = "this is the file content for the testItCanDownloadCode test"; diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java index a18a1abd38..3fb7b87bf1 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/knowledge/KnowledgeControllerTests.java @@ -278,8 +278,7 @@ public void variableExtractionWithModelTests() throws Exception { DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") - .setDescription("my description") - ; + .setDescription("my description"); documentAsset = documentAssetService.createAsset(documentAsset); @@ -341,7 +340,7 @@ public void cosmosPdfExtraction() throws Exception { final HttpEntity pdfFileEntity = new ByteArrayEntity(content, ContentType.create("application/pdf")); - DocumentAsset documentAsset = (DocumentAsset)new DocumentAsset() + DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() .setFileNames(List.of("paper.pdf")) .setName("test-pdf-name") .setDescription("my description"); @@ -363,8 +362,8 @@ public void cosmosPdfExtraction() throws Exception { public void profileModel() throws Exception { DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - .setText( - """ + .setText( + """ In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a theoretical framework to investigate its spread within a community. Here, the model is based upon the @@ -413,8 +412,8 @@ public void profileDataset() throws Exception { final ClassPathResource resource = new ClassPathResource("knowledge/dataset.csv"); final byte[] content = Files.readAllBytes(resource.getFile().toPath()); - Dataset dataset = datasetService.createAsset((Dataset) - new Dataset().setName("test-dataset-name").setDescription("my description")); + Dataset dataset = datasetService.createAsset( + (Dataset) new Dataset().setName("test-dataset-name").setDescription("my description")); // Create a MockMultipartFile object final MockMultipartFile file = new MockMultipartFile( @@ -437,8 +436,8 @@ public void profileDataset() throws Exception { .andExpect(status().isOk()); DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - .setText( - """ + .setText( + """ In this paper, we study the effectiveness of the modelling approach on the pandemic due to the spreading of the novel COVID-19 disease and develop a susceptible-infected-removed (SIR) model that provides a theoretical framework to investigate its spread within a community. Here, the model is based upon the @@ -489,10 +488,8 @@ public void codeToAmrTest() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset((Code) new Code() - .setFiles(files) - .setName("test-code-name") - .setDescription("my description")); + final Code code = codeService.createAsset( + (Code) new Code().setFiles(files).setName("test-code-name").setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); @@ -523,10 +520,8 @@ public void codeToAmrTestLLM() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset((Code) new Code() - .setFiles(files) - .setName("test-code-name") - .setDescription("my description")); + final Code code = codeService.createAsset( + (Code) new Code().setFiles(files).setName("test-code-name").setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); @@ -558,10 +553,8 @@ public void codeToAmrTestDynamicsOnly() throws Exception { final Map files = new HashMap<>(); files.put(filename, codeFile); - final Code code = codeService.createAsset((Code)new Code() - .setFiles(files) - .setName("test-code-name") - .setDescription("my description")); + final Code code = codeService.createAsset( + (Code) new Code().setFiles(files).setName("test-code-name").setDescription("my description")); final HttpEntity fileEntity = new ByteArrayEntity(content, ContentType.APPLICATION_OCTET_STREAM); codeService.uploadFile(code.getId(), filename, fileEntity, ContentType.TEXT_PLAIN); diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java index b495254028..5e68c9ae82 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/ExtractionServiceTests.java @@ -59,7 +59,7 @@ public void teardown() throws IOException { public void variableExtractionTests() throws Exception { DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - .setText("x = 0. y = 1. I = Infected population.") + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") .setDescription("my description"); @@ -78,8 +78,7 @@ public void variableExtractionWithModelTests() throws Exception { final byte[] content1 = Files.readAllBytes(resource1.getFile().toPath()); DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - - .setText(new String(content1)) + .setText(new String(content1)) .setName("test-document-name") .setDescription("my description"); @@ -101,8 +100,7 @@ public void variableExtractionWithModelTests() throws Exception { public void linkAmrTests() throws Exception { DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - - .setText("x = 0. y = 1. I = Infected population.") + .setText("x = 0. y = 1. I = Infected population.") .setName("test-document-name") .setDescription("my description"); @@ -131,7 +129,7 @@ public void cosmosPdfExtraction() throws Exception { final HttpEntity pdfFileEntity = new ByteArrayEntity(content, ContentType.create("application/pdf")); DocumentAsset documentAsset = (DocumentAsset) new DocumentAsset() - .setFileNames(List.of("paper.pdf")) + .setFileNames(List.of("paper.pdf")) .setName("test-pdf-name") .setDescription("my description"); From 5aa20494b43697c52d784ed59858e6ad3228fef8 Mon Sep 17 00:00:00 2001 From: dvince Date: Mon, 29 Apr 2024 14:53:36 -0400 Subject: [PATCH 3/6] task[hmi-server] - server cleanup * I angered the javascript gods with that one --- packages/client/hmi-client/src/components/code/tera-code.vue | 2 +- .../tera-calibrate-ensemble-ciemss.vue | 2 +- .../workflow/ops/model-config/tera-model-config.vue | 2 +- .../tera-simulate-ensemble-ciemss.vue | 2 +- packages/client/hmi-client/src/page/Home.vue | 4 +++- .../src/page/data-explorer/components/tera-asset-card.vue | 2 +- .../data-explorer/components/tera-search-results-list.vue | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/client/hmi-client/src/components/code/tera-code.vue b/packages/client/hmi-client/src/components/code/tera-code.vue index 5144626890..bfcb3f6894 100644 --- a/packages/client/hmi-client/src/components/code/tera-code.vue +++ b/packages/client/hmi-client/src/components/code/tera-code.vue @@ -508,7 +508,7 @@ watch( const code = await getCodeAsset(props.assetId); if (code && code.files && Object.keys(code.files)[0]) { codeAsset.value = code; - codeName.value = code.name; + codeName.value = code.name ?? ''; const filename = Object.keys(code.files)[0]; codeSelectedFile.value = filename; diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ensemble-ciemss/tera-calibrate-ensemble-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ensemble-ciemss/tera-calibrate-ensemble-ciemss.vue index 7c61ab5a99..d2f2826d23 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ensemble-ciemss/tera-calibrate-ensemble-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ensemble-ciemss/tera-calibrate-ensemble-ciemss.vue @@ -373,7 +373,7 @@ onMounted(async () => { csvAsset.value = csv; datasetColumnNames.value = csv?.headers; - listModelLabels.value = allModelConfigurations.value.map((ele) => ele.name); + listModelLabels.value = allModelConfigurations.value.map((ele) => ele.name ?? ''); // initalize ensembleConfigs when its length is less than the amount of models provided to node (- 1 due to dataset, -1 due to last empty ) if (knobs.value.ensembleConfigs.length < props.node.inputs.length - 2) { diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue index 89198dfb16..d149499f95 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue @@ -715,7 +715,7 @@ const createConfiguration = async (force: boolean = false) => { const data = await createModelConfiguration( model.value.id, - knobs.value?.transientModelConfig?.name, + knobs.value?.transientModelConfig?.name ?? '', knobs.value?.transientModelConfig?.description ?? '', knobs.value?.transientModelConfig?.configuration ); diff --git a/packages/client/hmi-client/src/components/workflow/ops/simulate-ensemble-ciemss/tera-simulate-ensemble-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/simulate-ensemble-ciemss/tera-simulate-ensemble-ciemss.vue index 9c25f236c3..fba60658cf 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/simulate-ensemble-ciemss/tera-simulate-ensemble-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/simulate-ensemble-ciemss/tera-simulate-ensemble-ciemss.vue @@ -351,7 +351,7 @@ onMounted(async () => { amr.semantics?.ode.observables?.forEach((element) => tempList.push(element.id)); allModelOptions.value[allModelConfigurations[i].id as string] = tempList; } - listModelLabels.value = allModelConfigurations.map((ele) => ele.name); + listModelLabels.value = allModelConfigurations.map((ele) => ele.name ?? ''); const state = _.cloneDeep(props.node.state); diff --git a/packages/client/hmi-client/src/page/Home.vue b/packages/client/hmi-client/src/page/Home.vue index 54dddd4591..26c97c4cfb 100644 --- a/packages/client/hmi-client/src/page/Home.vue +++ b/packages/client/hmi-client/src/page/Home.vue @@ -232,7 +232,9 @@ function sortProjectByDates(projects: Project[], dateType: DateType, sorting: 'A function filterAndSortProjects(projects: Project[]) { if (projects) { if (selectedSort.value === 'Alphabetical') { - return projects.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())); + return projects.sort((a, b) => + (a.name ?? '').toLowerCase().localeCompare((b.name ?? '').toLowerCase()) + ); } if (selectedSort.value === 'Last updated (descending)') { return sortProjectByDates(projects, 'updatedOn', 'DESC'); diff --git a/packages/client/hmi-client/src/page/data-explorer/components/tera-asset-card.vue b/packages/client/hmi-client/src/page/data-explorer/components/tera-asset-card.vue index a9c5f6963d..6f1389da28 100644 --- a/packages/client/hmi-client/src/page/data-explorer/components/tera-asset-card.vue +++ b/packages/client/hmi-client/src/page/data-explorer/components/tera-asset-card.vue @@ -228,7 +228,7 @@ const title = computed(() => { } else if (props.resourceType === ResourceType.MODEL) { value = (props.asset as Model).header.name; } else if (props.resourceType === ResourceType.DATASET) { - value = (props.asset as Dataset).name; + value = (props.asset as Dataset).name ?? ''; } return highlightSearchTerms(value); }); diff --git a/packages/client/hmi-client/src/page/data-explorer/components/tera-search-results-list.vue b/packages/client/hmi-client/src/page/data-explorer/components/tera-search-results-list.vue index 1fef7a6682..b1b74cad79 100644 --- a/packages/client/hmi-client/src/page/data-explorer/components/tera-search-results-list.vue +++ b/packages/client/hmi-client/src/page/data-explorer/components/tera-search-results-list.vue @@ -168,7 +168,7 @@ const projectOptions = computed(() => [ // then, link and store in the project assets if (datasetId) { response = await useProjects().addAsset(AssetType.Dataset, datasetId, project.id); - assetName = selectedAsset.value.name; + assetName = selectedAsset.value.name ?? ''; } } else if (isDocument(selectedAsset.value) && props.source === DocumentSource.XDD) { const document = selectedAsset.value as Document; From 09d0267999538786b308f34bddebc33effea2bd9 Mon Sep 17 00:00:00 2001 From: dvince Date: Mon, 29 Apr 2024 15:04:55 -0400 Subject: [PATCH 4/6] task[hmi-server] - server cleanup * fix server test --- .../dataservice/ModelConfigurationControllerTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java index 274a3134b1..2393452390 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java @@ -82,11 +82,11 @@ public void testItCanCreateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUpdateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = (ModelConfiguration) new ModelConfiguration() - .setModelId(UUID.randomUUID()) - .setConfiguration(new Model()) - .setDescription("test-desc") - .setName("test-framework"); + final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset((ModelConfiguration)new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework")); mockMvc.perform(MockMvcRequestBuilders.put("/model-configurations/" + modelConfiguration.getId()) .with(csrf()) From a9fe46cfca4f020fa987349ce299711450a79750 Mon Sep 17 00:00:00 2001 From: dvince2 Date: Mon, 29 Apr 2024 19:05:42 +0000 Subject: [PATCH 5/6] chore: lint server codebase --- .../ModelConfigurationControllerTests.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java index 2393452390..3898526055 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/ModelConfigurationControllerTests.java @@ -82,11 +82,12 @@ public void testItCanCreateModelConfiguration() throws Exception { @WithUserDetails(MockUser.URSULA) public void testItCanUpdateModelConfiguration() throws Exception { - final ModelConfiguration modelConfiguration = modelConfigurationService.createAsset((ModelConfiguration)new ModelConfiguration() - .setModelId(UUID.randomUUID()) - .setConfiguration(new Model()) - .setDescription("test-desc") - .setName("test-framework")); + final ModelConfiguration modelConfiguration = + modelConfigurationService.createAsset((ModelConfiguration) new ModelConfiguration() + .setModelId(UUID.randomUUID()) + .setConfiguration(new Model()) + .setDescription("test-desc") + .setName("test-framework")); mockMvc.perform(MockMvcRequestBuilders.put("/model-configurations/" + modelConfiguration.getId()) .with(csrf()) From 7c998433eb4ff3607f458a0a213bf5a9bed7bc74 Mon Sep 17 00:00:00 2001 From: dvince Date: Mon, 29 Apr 2024 16:19:14 -0400 Subject: [PATCH 6/6] task[hmi-server] - server cleanup * PR feedback changing to 512 --- .../uncharted/terarium/hmiserver/models/TerariumAsset.java | 2 +- .../db/migration/V4__Change_description_to_text.sql | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java index 636f5f7582..502988f1e4 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/TerariumAsset.java @@ -28,7 +28,7 @@ public abstract class TerariumAsset implements Serializable { private UUID id = UUID.randomUUID(); @TSOptional - @Column(length = 255) + @Column(length = 512) @Schema(defaultValue = "Default Name") private String name; diff --git a/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql b/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql index 85a155af56..80e0a816f0 100644 --- a/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql +++ b/packages/server/src/main/resources/db/migration/V4__Change_description_to_text.sql @@ -1,6 +1,13 @@ BEGIN; + ALTER TABLE simulation ALTER COLUMN result_files TYPE VARCHAR(1024)[]; + +ALTER TABLE simulation ALTER COLUMN name TYPE VARCHAR(512); +ALTER TABLE workflow ALTER COLUMN name TYPE VARCHAR(512); +ALTER TABLE project ALTER COLUMN name TYPE VARCHAR(512); + ALTER TABLE simulation ALTER COLUMN description TYPE text; ALTER TABLE workflow ALTER COLUMN description TYPE text; ALTER TABLE project ALTER COLUMN description TYPE text; + COMMIT;