diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java index fd2389780..3c5c4d2ce 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.junit.Ignore; import org.junit.jupiter.api.TestInfo; import com.fasterxml.jackson.core.JsonProcessingException; @@ -224,7 +225,7 @@ private void testImportExport(boolean wipe) throws InterruptedException { addMissingDataRule(test, "Let me know", JsonNodeFactory.instance.arrayNode().add("foo"), null, (int) TimeUnit.DAYS.toMillis(1)); - addExperimentProfile(test, "Some profile", VariableDAO. listAll().get(0)); + addExperimentProfile(test, "Some profile", VariableDAO.listAll().get(0)); addSubscription(test); HashMap> db = dumpDatabaseContents(); @@ -277,7 +278,7 @@ public void testImportWithTransformers() { String t = readFile(p.resolve("quarkus_sb_test.json").toFile()); jsonRequest().body(t).post("/api/test/import").then().statusCode(201); - TestDAO test = TestDAO. find("name", "quarkus-spring-boot-comparison").firstResult(); + TestDAO test = TestDAO.find("name", "quarkus-spring-boot-comparison").firstResult(); assertEquals(1, test.transformers.size()); List descriptors = jsonRequest().get("/api/schema/descriptors") @@ -312,7 +313,7 @@ public void testExportImportWithExistingDatastore() { assertEquals(2, TestDAO.count()); - TestDAO imported = TestDAO. find("name", "imported-test").firstResult(); + TestDAO imported = TestDAO.find("name", "imported-test").firstResult(); assertNotNull(imported); assertNotEquals(test.id, imported.id); @@ -351,7 +352,7 @@ public void testExportImportWithNotExistingDatastore() { assertEquals(2, TestDAO.count()); - TestDAO imported = TestDAO. find("name", "imported-test").firstResult(); + TestDAO imported = TestDAO.find("name", "imported-test").firstResult(); assertNotNull(imported); assertNotEquals(test.id, imported.id); @@ -463,9 +464,9 @@ public void testImportTestWithChangeDetectionVariable() { TestExport testExport = jsonRequest().get("/api/test/" + importedId + "/export").then() .statusCode(200).extract().as(TestExport.class); assertEquals(importedId, testExport.id); - assertNull(VariableDAO. find("name", "Max RSS (v2)").firstResult()); + assertNull(VariableDAO.find("name", "Max RSS (v2)").firstResult()); - VariableDAO maxRSS = VariableDAO. find("name", "Max RSS").firstResult(); + VariableDAO maxRSS = VariableDAO.find("name", "Max RSS").firstResult(); assertNotNull(maxRSS); assertEquals("Max RSS", maxRSS.name); Variable var = VariableMapper.from(maxRSS); @@ -481,7 +482,7 @@ public void testImportTestWithChangeDetectionVariable() { .as(Integer.class); assertEquals(importedId, updatedId); - VariableDAO varDAO = VariableDAO. find("name", "Max RSS (v2)").firstResult(); + VariableDAO varDAO = VariableDAO.find("name", "Max RSS (v2)").firstResult(); assertNotNull(varDAO); } @@ -496,7 +497,7 @@ public void testImportTestWithExperimentProfile() { .statusCode(200).extract().as(TestExport.class); assertEquals(importedId, testExport.id); - VariableDAO maxRSS = VariableDAO. find("name", "Max RSS").firstResult(); + VariableDAO maxRSS = VariableDAO.find("name", "Max RSS").firstResult(); assertNotNull(maxRSS); assertEquals("Max RSS", maxRSS.name); Variable var = VariableMapper.from(maxRSS); @@ -533,7 +534,7 @@ public void testImportTestWithExperimentProfile() { .as(Integer.class); assertEquals(importedId, updatedId); - ExperimentProfileDAO epDAO = ExperimentProfileDAO. find("name", "acme Quarkus experiment") + ExperimentProfileDAO epDAO = ExperimentProfileDAO.find("name", "acme Quarkus experiment") .firstResult(); assertNotNull(epDAO); assertEquals(1, epDAO.comparisons.size()); @@ -577,7 +578,7 @@ private void addSubscription(Test test) { // utility to get list of schemas private TestService.TestQueryResult listTests(String token, String roles, Integer limit, Integer page, String sort, - SortDirection direction) { + SortDirection direction) { StringBuilder query = new StringBuilder("/api/test/"); if (roles != null || limit != null || page != null || sort != null || direction != null) { query.append("?"); @@ -629,7 +630,7 @@ void testUpdateLabelsOnRuns() throws IOException, InterruptedException { String t = readFile(p.resolve("quarkus_sb_test.json").toFile()); Integer testId = jsonRequest().body(t).post("/api/test/import").then().statusCode(201).extract().as(Integer.class); - TestDAO test = TestDAO. find("name", "quarkus-spring-boot-comparison").firstResult(); + TestDAO test = TestDAO.find("name", "quarkus-spring-boot-comparison").firstResult(); assertEquals(1, test.transformers.size()); //let's get all the labels to make sure they're all there @@ -703,4 +704,47 @@ void testUpdateLabelsOnRuns() throws IOException, InterruptedException { } assertEquals(oldMaxId + 80, maxId.getAsInt()); } + + @org.junit.jupiter.api.Test + void testDeleteVariable() throws IOException, InterruptedException { + Path p = new File(getClass().getClassLoader().getResource(".").getPath()).toPath(); + p = p.getParent().getParent().getParent().resolve("infra-legacy/example-data/"); + ObjectMapper mapper = new ObjectMapper(); + String s = readFile(p.resolve("quarkus_sb_schema.json").toFile()); + Integer schemaId = jsonRequest().body(s).post("/api/schema/import").then().statusCode(201).extract().as(Integer.class); + + s = readFile(p.resolve("quarkus_sb_compare_ds.json").toFile()); + Integer schemaId2 = jsonRequest().body(s).post("/api/schema/import").then().statusCode(201).extract().as(Integer.class); + assertTrue(schemaId2 > schemaId); + + String t = readFile(p.resolve("quarkus_sb_test.json").toFile()); + Integer testId = jsonRequest().body(t).post("/api/test/import").then().statusCode(201).extract().as(Integer.class); + + TestDAO test = TestDAO.find("name", "quarkus-spring-boot-comparison").firstResult(); + assertEquals(1, test.transformers.size()); + + //let's get all the labels to make sure they're all there + List