From 21abea9aa87da6aace51a0f59df5d14fed297f3b Mon Sep 17 00:00:00 2001 From: cnathe Date: Sat, 23 Aug 2025 08:24:44 -0500 Subject: [PATCH 1/2] Fix up domain create/delete for PropertyController TestCase --- .../property/PropertyController.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java index 35eb30a598f..6cbe9895bb5 100644 --- a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java +++ b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java @@ -2200,8 +2200,6 @@ public void setPropertyURIs(List propertyURIs) public static class TestCase extends Assert { - private static Domain domain; - @BeforeClass public static void initialSetUp() throws ValidationException { @@ -2229,14 +2227,23 @@ public static void initialSetUp() throws ValidationException gwtDomain.setFields(gwtProps); - domain = DomainUtil.createDomain(VocabularyDomainKind.KIND_NAME, gwtDomain, null, c, user, domainName, null, false); + DomainUtil.createDomain(VocabularyDomainKind.KIND_NAME, gwtDomain, null, c, user, domainName, null, false); + } + + static Domain getDomain() + { + Container c = JunitUtil.getTestContainer(); + User user = TestContext.get().getUser(); + String domainName = "TestVocabularyDomain"; + DomainKind kind = PropertyService.get().getDomainKindByName(VocabularyDomainKind.KIND_NAME); + return PropertyService.get().getDomain(c, kind.generateDomainURI(null, domainName, c, user)); } @AfterClass public static void tearDown() throws DomainNotFoundException { User user = TestContext.get().getUser(); - domain.delete(user); + getDomain().delete(user); } @Test @@ -2244,6 +2251,7 @@ public void testGetDomains() throws ValidationException { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); + Domain domain = getDomain(); Set domainKinds = new HashSet<>(); domainKinds.add(VocabularyDomainKind.KIND_NAME); @@ -2259,6 +2267,7 @@ public void testGetProperties() throws ValidationException { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); + Domain domain = getDomain(); var props = domain.getProperties().stream().map(DomainProperty::getPropertyDescriptor).collect(Collectors.toSet()); @@ -2307,6 +2316,7 @@ public void testPropertyUsages() throws Exception { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); + Domain domain = getDomain(); var intProp = domain.getPropertyByName("testIntField"); var stringProp = domain.getPropertyByName("testStringField"); From ed98b957630419280e52a25a1b0899f88974ecc0 Mon Sep 17 00:00:00 2001 From: cnathe Date: Sat, 23 Aug 2025 08:36:58 -0500 Subject: [PATCH 2/2] revert to changes before last PR --- .../property/PropertyController.java | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java index 6cbe9895bb5..99f5d24db13 100644 --- a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java +++ b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java @@ -2200,8 +2200,7 @@ public void setPropertyURIs(List propertyURIs) public static class TestCase extends Assert { - @BeforeClass - public static void initialSetUp() throws ValidationException + Domain createVocabDomain() throws ValidationException { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); @@ -2227,23 +2226,7 @@ public static void initialSetUp() throws ValidationException gwtDomain.setFields(gwtProps); - DomainUtil.createDomain(VocabularyDomainKind.KIND_NAME, gwtDomain, null, c, user, domainName, null, false); - } - - static Domain getDomain() - { - Container c = JunitUtil.getTestContainer(); - User user = TestContext.get().getUser(); - String domainName = "TestVocabularyDomain"; - DomainKind kind = PropertyService.get().getDomainKindByName(VocabularyDomainKind.KIND_NAME); - return PropertyService.get().getDomain(c, kind.generateDomainURI(null, domainName, c, user)); - } - - @AfterClass - public static void tearDown() throws DomainNotFoundException - { - User user = TestContext.get().getUser(); - getDomain().delete(user); + return DomainUtil.createDomain(VocabularyDomainKind.KIND_NAME, gwtDomain, null, c, user, domainName, null, false); } @Test @@ -2251,7 +2234,7 @@ public void testGetDomains() throws ValidationException { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); - Domain domain = getDomain(); + Domain domain = createVocabDomain(); Set domainKinds = new HashSet<>(); domainKinds.add(VocabularyDomainKind.KIND_NAME); @@ -2267,7 +2250,7 @@ public void testGetProperties() throws ValidationException { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); - Domain domain = getDomain(); + Domain domain = createVocabDomain(); var props = domain.getProperties().stream().map(DomainProperty::getPropertyDescriptor).collect(Collectors.toSet()); @@ -2316,7 +2299,7 @@ public void testPropertyUsages() throws Exception { Container c = JunitUtil.getTestContainer(); User user = TestContext.get().getUser(); - Domain domain = getDomain(); + Domain domain = createVocabDomain(); var intProp = domain.getPropertyByName("testIntField"); var stringProp = domain.getPropertyByName("testStringField");