From 50bfcff9be9ceee9d33f1cf75b3f329000959b3e Mon Sep 17 00:00:00 2001 From: Daniel Chang Date: Fri, 16 Aug 2024 11:48:09 -0400 Subject: [PATCH] update tests --- .../service/data/WorkflowService.java | 28 +------ .../dataservice/WorkflowControllerTests.java | 6 +- .../data/TerariumAssetCloneServiceTests.java | 2 - .../service/data/WorkflowServiceTests.java | 76 +------------------ 4 files changed, 4 insertions(+), 108 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/WorkflowService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/WorkflowService.java index c201ac9bac..d33a06008e 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/WorkflowService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/WorkflowService.java @@ -22,41 +22,17 @@ import software.uncharted.terarium.hmiserver.utils.rebac.Schema; @Service -public class WorkflowService extends TerariumAssetServiceWithSearch { +public class WorkflowService extends TerariumAssetServiceWithoutSearch { public WorkflowService( final ObjectMapper objectMapper, final Config config, - final ElasticsearchConfiguration elasticConfig, - final ElasticsearchService elasticService, final ProjectService projectService, final ProjectAssetService projectAssetService, final S3ClientService s3ClientService, final WorkflowRepository repository ) { - super( - objectMapper, - config, - elasticConfig, - elasticService, - projectService, - projectAssetService, - s3ClientService, - repository, - Workflow.class - ); - } - - @Override - @Observed(name = "function_profile") - protected String getAssetIndex() { - return elasticConfig.getWorkflowIndex(); - } - - @Override - @Observed(name = "function_profile") - public String getAssetAlias() { - return elasticConfig.getWorkflowAlias(); + super(objectMapper, config, projectService, projectAssetService, repository, s3ClientService, Workflow.class); } @Override diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/WorkflowControllerTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/WorkflowControllerTests.java index 1a031f3e7b..d09c3a9d4f 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/WorkflowControllerTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/controller/dataservice/WorkflowControllerTests.java @@ -34,17 +34,13 @@ public class WorkflowControllerTests extends TerariumApplicationTests { @BeforeEach public void setup() throws IOException { - workflowService.setupIndexAndAliasAndEnsureEmpty(); - project = projectService.createProject( (Project) new Project().setPublicAsset(true).setName("test-project-name").setDescription("my description") ); } @AfterEach - public void teardown() throws IOException { - workflowService.teardownIndexAndAlias(); - } + public void teardown() throws IOException {} @Test @WithUserDetails(MockUser.URSULA) diff --git a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/TerariumAssetCloneServiceTests.java b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/TerariumAssetCloneServiceTests.java index fe5f53bbcb..f5a509ad70 100644 --- a/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/TerariumAssetCloneServiceTests.java +++ b/packages/server/src/test/java/software/uncharted/terarium/hmiserver/service/data/TerariumAssetCloneServiceTests.java @@ -55,7 +55,6 @@ public class TerariumAssetCloneServiceTests extends TerariumApplicationTests { @BeforeEach public void setup() throws IOException { documentService.setupIndexAndAliasAndEnsureEmpty(); - workflowService.setupIndexAndAliasAndEnsureEmpty(); project = projectService.createProject( (Project) new Project().setPublicAsset(true).setName("test-project-name").setDescription("my description") ); @@ -64,7 +63,6 @@ public void setup() throws IOException { @AfterEach public void teardown() throws IOException { documentService.setupIndexAndAliasAndEnsureEmpty(); - workflowService.setupIndexAndAliasAndEnsureEmpty(); } static Grounding createGrounding(final String key) { 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 2c624a0f83..cd2a214380 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 @@ -39,16 +39,13 @@ public class WorkflowServiceTests extends TerariumApplicationTests { @BeforeEach public void setup() throws IOException { - workflowService.setupIndexAndAliasAndEnsureEmpty(); project = projectService.createProject( (Project) new Project().setPublicAsset(true).setName("test-project-name").setDescription("my description") ); } @AfterEach - public void teardown() throws IOException { - workflowService.teardownIndexAndAlias(); - } + public void teardown() throws IOException {} static Workflow createWorkflow() throws Exception { final WorkflowNode a = new WorkflowNode().setId(UUID.randomUUID()); @@ -270,75 +267,4 @@ public void testWorkflowsAreOpaque() throws Exception { Assertions.assertTrue(n.has("somethingElse")); }); } - - @Test - @WithUserDetails(MockUser.URSULA) - public void testItCanSearchAssets() throws Exception { - final int NUM = 32; - - List workflows = new ArrayList<>(); - for (int i = 0; i < NUM; i++) { - workflows.add(createWorkflow(String.valueOf(i))); - } - workflows = workflowService.createAssets(workflows, project.getId(), Schema.Permission.WRITE); - - final List results = workflowService.searchAssets(0, NUM, null); - - Assertions.assertEquals(NUM, results.size()); - - for (int i = 0; i < results.size(); i++) { - Assertions.assertEquals(workflows.get(i).getName(), results.get(i).getName()); - Assertions.assertEquals(workflows.get(i).getDescription(), results.get(i).getDescription()); - Assertions.assertEquals(workflows.get(i).getTransform(), results.get(i).getTransform()); - Assertions.assertEquals( - workflows.get(i).getCreatedOn().toInstant().getEpochSecond(), - results.get(i).getCreatedOn().toInstant().getEpochSecond() - ); - Assertions.assertEquals( - workflows.get(i).getUpdatedOn().toInstant().getEpochSecond(), - results.get(i).getUpdatedOn().toInstant().getEpochSecond() - ); - Assertions.assertEquals(workflows.get(i).getDeletedOn(), results.get(i).getDeletedOn()); - Assertions.assertEquals(workflows.get(i).getNodes().size(), results.get(i).getNodes().size()); - for (int j = 0; j < results.get(i).getNodes().size(); j++) { - Assertions.assertEquals(workflows.get(i).getNodes().get(j).getId(), results.get(i).getNodes().get(j).getId()); - Assertions.assertEquals( - workflows.get(i).getNodes().get(j).getWorkflowId(), - results.get(i).getNodes().get(j).getWorkflowId() - ); - } - Assertions.assertEquals(workflows.get(i).getEdges().size(), results.get(i).getEdges().size()); - for (int j = 0; j < results.get(i).getEdges().size(); j++) { - Assertions.assertEquals(workflows.get(i).getEdges().get(j).getId(), results.get(i).getEdges().get(j).getId()); - Assertions.assertEquals( - workflows.get(i).getEdges().get(j).getWorkflowId(), - results.get(i).getEdges().get(j).getWorkflowId() - ); - } - } - } - - @Test - @WithUserDetails(MockUser.URSULA) - public void testItCanSyncToNewIndex() throws Exception { - final int NUM = 32; - - final List workflows = new ArrayList<>(); - for (int i = 0; i < NUM; i++) { - workflows.add(createWorkflow(String.valueOf(i))); - } - workflowService.createAssets(workflows, project.getId(), Schema.Permission.WRITE); - - final String currentIndex = workflowService.getCurrentAssetIndex(); - - Assertions.assertEquals(NUM, workflowService.searchAssets(0, NUM, null).size()); - - workflowService.syncAllAssetsToNewIndex(true); - - final String newIndex = workflowService.getCurrentAssetIndex(); - - Assertions.assertEquals(NUM, workflowService.searchAssets(0, NUM, null).size()); - - Assertions.assertNotEquals(currentIndex, newIndex); - } }