diff --git a/api/schemas/domainTemplate.xsd b/api/schemas/domainTemplate.xsd
index 12614675f79..e5472bfa5cc 100644
--- a/api/schemas/domainTemplate.xsd
+++ b/api/schemas/domainTemplate.xsd
@@ -46,6 +46,15 @@
+
+
+
+ Additional column names that should be considered reserved by the DomainKind for any
+ domain created from this template. These names are unioned with the DomainKind's
+ statically reserved set.
+
+
+
diff --git a/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java b/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java
index 5068f6e3218..d2f3df362f1 100644
--- a/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java
+++ b/api/src/org/labkey/api/audit/query/AbstractAuditDomainKind.java
@@ -298,7 +298,7 @@ public boolean hasNullValues(Domain domain, DomainProperty prop)
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
Set names = new HashSet<>();
diff --git a/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java b/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java
index 472427fbc1f..00bea3e08b9 100644
--- a/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java
+++ b/api/src/org/labkey/api/exp/api/SampleTypeDomainKind.java
@@ -261,13 +261,7 @@ public Set getBaseProperties(Domain domain)
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
- {
- return getReservedPropertyNames(domain, user, false);
- }
-
- @Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user, boolean forCreate)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
Set reserved = new CaseInsensitiveHashSet(RESERVED_NAMES);
diff --git a/api/src/org/labkey/api/exp/property/DomainKind.java b/api/src/org/labkey/api/exp/property/DomainKind.java
index da4cda6b2d0..0a0e70c4d50 100644
--- a/api/src/org/labkey/api/exp/property/DomainKind.java
+++ b/api/src/org/labkey/api/exp/property/DomainKind.java
@@ -61,9 +61,9 @@ abstract public class DomainKind implements Handler
abstract public String getKindName();
/**
- * Return a class of DomainKind's bean which carries domain specific properties.
- * This class will be used when marshalling/unmarshalling via Jackson during Create and Save/Update Domain
- * @return Class of DomainKind's bean with domain specific properties
+ * Return a class of DomainKind's bean which carries domain-specific properties.
+ * This class will be used when marshaling/unmarshaling via Jackson during Create and Save/Update Domain
+ * @return Class of DomainKind's bean with domain-specific properties
*/
abstract public Class extends T> getTypeClass();
@@ -108,15 +108,65 @@ public Map processArguments(Container container, User user, Map<
abstract public void deletePropertyDescriptor(Domain domain, User user, PropertyDescriptor pd);
/**
- * Return the set of names that should not be allowed for properties. E.g.
- * the names of columns from the hard table underlying this type
+ * Return the set of names that should not be allowed for properties. E.g., the names of columns
+ * from the hard table underlying this type, unioned with any names declared in the
+ * {@link DomainTemplate}'s {@code } element that this domain was created from.
+ *
+ * This method is {@code final}; subclasses contribute their kind-specific reserved set by overriding
+ * {@link #getKindReservedPropertyNames(Domain, User, boolean)}. The base class always unions that
+ * set with the template-declared set.
+ *
* @return set of strings containing the names. This will be compared ignoring case
*/
- abstract public Set getReservedPropertyNames(Domain domain, User user);
+ @NotNull
+ public final Set getReservedPropertyNames(Domain domain, User user)
+ {
+ return getReservedPropertyNames(domain, user, false);
+ }
+
+ @NotNull
+ public final Set getReservedPropertyNames(Domain domain, User user, boolean forCreate)
+ {
+ Set reserved = new CaseInsensitiveHashSet(getKindReservedPropertyNames(domain, user, forCreate));
+ reserved.addAll(getTemplateReservedPropertyNames(domain));
+ return reserved;
+ }
+
+ /**
+ * Return the kind-specific set of names that should not be allowed for properties. Subclasses override
+ * this to contribute their static/hard-coded reserved names. The base class will automatically union
+ * the result with any names declared in the {@link DomainTemplate}'s {@code }
+ * element via {@link #getReservedPropertyNames(Domain, User, boolean)}.
+ *
+ * @param forCreate true when validating names during domain creation; some kinds reserve additional
+ * names only at creation time.
+ * @return set of strings containing the names.
+ */
+ @NotNull
+ protected Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
+ {
+ return Collections.emptySet();
+ }
- public Set getReservedPropertyNames(Domain domain, User user, boolean forCreate)
+ /**
+ * Returns reserved column names declared in the {@link DomainTemplate} that this domain was created from
+ * (if any). These extend the kind's statically reserved set.
+ */
+ @NotNull
+ protected Set getTemplateReservedPropertyNames(@Nullable Domain domain)
{
- return getReservedPropertyNames(domain, user);
+ if (domain == null)
+ return Collections.emptySet();
+
+ TemplateInfo info = domain.getTemplateInfo();
+ if (info == null)
+ return Collections.emptySet();
+
+ DomainTemplate template = DomainTemplate.findTemplate(info, getKindName());
+ if (template == null)
+ return Collections.emptySet();
+
+ return template.getReservedColumnNames();
}
public Set getReservedPropertyNamePrefixes()
@@ -132,14 +182,14 @@ public Set getReservedPropertyNamePrefixes()
abstract public Set getMandatoryPropertyNames(Domain domain);
// CONSIDER: have DomainKind supply and IDomainInstance or similar
- // so that it can hold instance data (e.g. a DatasetDefinition)
+ // so that it can hold instance data (e.g., a DatasetDefinition)
/**
* Get DomainKind specific properties.
* @param domain The domain design.
* @param container Container
* @param user User
- * @return Return object that holds DomainKind specific properties.
+ * @return Return an object that holds DomainKind specific properties.
*/
abstract public @Nullable T getDomainKindProperties(GWTDomain> domain, Container container, User user);
diff --git a/api/src/org/labkey/api/exp/property/DomainTemplate.java b/api/src/org/labkey/api/exp/property/DomainTemplate.java
index 5eb5ec5b761..00788895d72 100644
--- a/api/src/org/labkey/api/exp/property/DomainTemplate.java
+++ b/api/src/org/labkey/api/exp/property/DomainTemplate.java
@@ -15,6 +15,7 @@
*/
package org.labkey.api.exp.property;
+import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
@@ -60,7 +61,6 @@
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -69,10 +69,6 @@
import java.util.Objects;
import java.util.Set;
-/**
- * User: kevink
- * Date: 1/6/16
- */
public class DomainTemplate
{
private final String _moduleName;
@@ -83,6 +79,7 @@ public class DomainTemplate
private final String _domainKind;
private final GWTDomain _domain;
private final Map _options;
+ private final Set _reservedColumnNames;
private final InitialDataSettings _initialData;
/**
@@ -132,7 +129,7 @@ public static DomainTemplate parse(String moduleName, String groupName, DomainTe
}
catch (IllegalArgumentException ex)
{
- return new DomainTemplate(Objects.toString(templateName, ""), moduleName, groupName, Arrays.asList(ex.getMessage()));
+ return new DomainTemplate(Objects.toString(templateName, ""), moduleName, groupName, List.of(ex.getMessage()));
}
}
@@ -148,8 +145,9 @@ private static DomainTemplate _parse(String templateName, String moduleName, Str
throw new IllegalArgumentException("Unknown template domain kind");
List indices = getDomainTemplateUniqueIndices(templateName, template, properties);
- Set mandatoryFieldNames = getDomainTemplateMandatoryFields(templateName, template, properties);
+ Set mandatoryFieldNames = getDomainTemplateMandatoryFields(template);
Map options = getDomainTemplateOptions(templateName, template, properties);
+ Set reservedColumnNames = getDomainTemplateReservedColumnNames(template);
GWTDomain domain = new GWTDomain<>();
domain.setName(templateName);
@@ -162,17 +160,33 @@ private static DomainTemplate _parse(String templateName, String moduleName, Str
return new DomainTemplate(
templateName, groupName, moduleName,
- domainKind, domain, options,
+ domainKind, domain, options, reservedColumnNames,
importData
);
}
+ private static Set getDomainTemplateReservedColumnNames(DomainTemplateType template)
+ {
+ if (!template.isSetReservedColumnNames())
+ return Collections.emptySet();
+
+ CaseInsensitiveHashSet set = new CaseInsensitiveHashSet();
+ for (String name : template.getReservedColumnNames().getColumnArray())
+ {
+ String validName = StringUtils.trimToNull(name);
+ if (validName != null)
+ set.add(validName);
+ }
+
+ return Collections.unmodifiableSet(set);
+ }
+
@Nullable
private static String getDomainKind(String templateName, DomainTemplateType template, List properties)
{
List> domainKinds = PropertyService.get().getDomainKinds();
- for (DomainKind domainKind : domainKinds)
+ for (DomainKind> domainKind : domainKinds)
{
if (domainKind.matchesTemplateXML(templateName, template, properties))
{
@@ -198,7 +212,7 @@ private static List getDomainTemplateProperties(String te
}
}
- return Collections.unmodifiableList(new ArrayList<>(properties.values()));
+ return List.copyOf(properties.values());
}
private static List getDomainTemplateUniqueIndices(String templateName, DomainTemplateType template, List properties)
@@ -227,7 +241,7 @@ private static List getDomainTemplateUniqueIndices(String templateName
return Collections.unmodifiableList(indices);
}
- private static Set getDomainTemplateMandatoryFields(String templateName, DomainTemplateType template, List properties)
+ private static Set getDomainTemplateMandatoryFields(DomainTemplateType template)
{
CaseInsensitiveHashSet set = new CaseInsensitiveHashSet();
@@ -266,9 +280,9 @@ private static Map getDomainTemplateOptions(String templateName,
{
Map optionsMap = new HashMap<>();
- if (template instanceof ListTemplateType)
+ if (template instanceof ListTemplateType listTemplate)
{
- ListOptionsType options = ((ListTemplateType)template).getOptions();
+ ListOptionsType options = listTemplate.getOptions();
String keyName = options.getKeyCol();
optionsMap.put("keyName", keyName);
@@ -276,9 +290,9 @@ private static Map getDomainTemplateOptions(String templateName,
if (options.isSetKeyType())
optionsMap.put("keyType", options.getKeyType());
}
- else if (template instanceof DataClassTemplateType)
+ else if (template instanceof DataClassTemplateType dataClassTemplate)
{
- DataClassOptionsType options = ((DataClassTemplateType)template).getOptions();
+ DataClassOptionsType options = dataClassTemplate.getOptions();
if (options != null)
{
optionsMap.put("nameExpression", options.getNameExpression());
@@ -288,9 +302,9 @@ else if (template instanceof DataClassTemplateType)
optionsMap.put("category", options.getCategory());
}
}
- else if (template instanceof SampleSetTemplateType)
+ else if (template instanceof SampleSetTemplateType sampleTypeTemplate)
{
- SampleSetOptionsType options = ((SampleSetTemplateType)template).getOptions();
+ SampleSetOptionsType options = sampleTypeTemplate.getOptions();
if (options != null)
{
optionsMap.put("nameExpression", options.getNameExpression());
@@ -338,8 +352,9 @@ private static InitialDataSettings getImportDataSettings(String templateName, Do
}
private DomainTemplate(@NotNull String name, @NotNull String groupName, @NotNull String moduleName,
- @NotNull String domainKind, @NotNull GWTDomain domain,
- @NotNull Map options, @Nullable InitialDataSettings initialData)
+ @NotNull String domainKind, @NotNull GWTDomain domain,
+ @NotNull Map options, @NotNull Set reservedColumnNames,
+ @Nullable InitialDataSettings initialData)
{
_moduleName = moduleName;
_templateGroup = groupName;
@@ -348,6 +363,7 @@ private DomainTemplate(@NotNull String name, @NotNull String groupName, @NotNull
_errors = null;
_domain = domain;
_options = options;
+ _reservedColumnNames = reservedColumnNames;
_initialData = initialData;
}
@@ -361,6 +377,7 @@ private DomainTemplate(@NotNull String name, @NotNull String groupName, @NotNull
_domainKind = null;
_domain = null;
_options = null;
+ _reservedColumnNames = Collections.emptySet();
_initialData = null;
}
@@ -568,6 +585,11 @@ public Set getMandatoryPropertyNames()
return _domain.getMandatoryFieldNames();
}
+ @NotNull
+ public Set getReservedColumnNames()
+ {
+ return _reservedColumnNames;
+ }
private static class InitialDataSettings
{
diff --git a/api/src/org/labkey/api/exp/property/TestDomainKind.java b/api/src/org/labkey/api/exp/property/TestDomainKind.java
index 99aabb991f7..eff13d44b8c 100644
--- a/api/src/org/labkey/api/exp/property/TestDomainKind.java
+++ b/api/src/org/labkey/api/exp/property/TestDomainKind.java
@@ -148,7 +148,7 @@ public void deletePropertyDescriptor(Domain domain, User user, PropertyDescripto
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
throw new UnsupportedOperationException();
}
diff --git a/api/src/org/labkey/api/query/SimpleTableDomainKind.java b/api/src/org/labkey/api/query/SimpleTableDomainKind.java
index b857ae91139..545985ebed2 100644
--- a/api/src/org/labkey/api/query/SimpleTableDomainKind.java
+++ b/api/src/org/labkey/api/query/SimpleTableDomainKind.java
@@ -236,7 +236,7 @@ public boolean canCreateDefinition(User user, Container container)
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
SimpleUserSchema.SimpleTable table = domain != null ? getTable(domain, user) : null;
if (table != null)
diff --git a/assay/api-src/org/labkey/api/assay/AssayBatchDomainKind.java b/assay/api-src/org/labkey/api/assay/AssayBatchDomainKind.java
index 890cfec7691..9ff76997f1c 100644
--- a/assay/api-src/org/labkey/api/assay/AssayBatchDomainKind.java
+++ b/assay/api-src/org/labkey/api/assay/AssayBatchDomainKind.java
@@ -25,10 +25,6 @@
import java.util.Arrays;
import java.util.Set;
-/**
- * User: jeckels
- * Date: Jan 27, 2012
- */
public class AssayBatchDomainKind extends AssayDomainKind
{
private static final Set RESERVED_NAMES;
@@ -50,7 +46,7 @@ public String getKindName()
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return RESERVED_NAMES;
}
diff --git a/assay/api-src/org/labkey/api/assay/AssayResultDomainKind.java b/assay/api-src/org/labkey/api/assay/AssayResultDomainKind.java
index c6de4802ecb..6ac6c91682b 100644
--- a/assay/api-src/org/labkey/api/assay/AssayResultDomainKind.java
+++ b/assay/api-src/org/labkey/api/assay/AssayResultDomainKind.java
@@ -127,7 +127,7 @@ public DbSchema getSchema()
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return RESERVED_NAMES;
}
diff --git a/assay/api-src/org/labkey/api/assay/AssayRunDomainKind.java b/assay/api-src/org/labkey/api/assay/AssayRunDomainKind.java
index 2915b7a10d6..9d7a0ab3bf4 100644
--- a/assay/api-src/org/labkey/api/assay/AssayRunDomainKind.java
+++ b/assay/api-src/org/labkey/api/assay/AssayRunDomainKind.java
@@ -53,7 +53,7 @@ public String getKindName()
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return RESERVED_NAMES;
}
diff --git a/assay/src/org/labkey/assay/DefaultAssayDomainKind.java b/assay/src/org/labkey/assay/DefaultAssayDomainKind.java
index 56fef31c8f8..b8bdd764277 100644
--- a/assay/src/org/labkey/assay/DefaultAssayDomainKind.java
+++ b/assay/src/org/labkey/assay/DefaultAssayDomainKind.java
@@ -43,7 +43,7 @@ public String getKindName()
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return getAssayReservedPropertyNames();
}
diff --git a/assay/src/org/labkey/assay/PlateBasedAssaySampleTypeDomainKind.java b/assay/src/org/labkey/assay/PlateBasedAssaySampleTypeDomainKind.java
index 9ab3ad3a777..772e1d30907 100644
--- a/assay/src/org/labkey/assay/PlateBasedAssaySampleTypeDomainKind.java
+++ b/assay/src/org/labkey/assay/PlateBasedAssaySampleTypeDomainKind.java
@@ -55,12 +55,6 @@ public String getKindName()
{
return null;
}
-
- @Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
- {
- return Collections.emptySet();
- }
};
}
diff --git a/assay/src/org/labkey/assay/plate/PlateMetadataDomainKind.java b/assay/src/org/labkey/assay/plate/PlateMetadataDomainKind.java
index 88d82a3a52e..e160a02edb8 100644
--- a/assay/src/org/labkey/assay/plate/PlateMetadataDomainKind.java
+++ b/assay/src/org/labkey/assay/plate/PlateMetadataDomainKind.java
@@ -217,7 +217,7 @@ public SQLFragment sqlObjectIdsInDomain(Domain domain)
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return RESERVED_NAMES;
}
diff --git a/assay/src/org/labkey/assay/plate/PlateReplicateStatsDomainKind.java b/assay/src/org/labkey/assay/plate/PlateReplicateStatsDomainKind.java
index a25e0911006..60cfa796b1e 100644
--- a/assay/src/org/labkey/assay/plate/PlateReplicateStatsDomainKind.java
+++ b/assay/src/org/labkey/assay/plate/PlateReplicateStatsDomainKind.java
@@ -51,7 +51,7 @@ public String getKindName()
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return getAssayReservedPropertyNames();
}
diff --git a/core/src/org/labkey/core/query/UsersDomainKind.java b/core/src/org/labkey/core/query/UsersDomainKind.java
index 34f17f07dbe..db44d254cdf 100644
--- a/core/src/org/labkey/core/query/UsersDomainKind.java
+++ b/core/src/org/labkey/core/query/UsersDomainKind.java
@@ -159,7 +159,7 @@ public Domain createDomain(GWTDomain domain, JSONObject arguments, Container con
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return _reservedNames;
}
diff --git a/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java b/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java
index 3b9d5d1cc8e..d10b8b7700f 100644
--- a/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java
+++ b/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java
@@ -232,7 +232,7 @@ public Set getBaseProperties(Domain domain)
}
@Override
- public @NotNull Set getReservedPropertyNames(Domain domain, User user)
+ protected @NotNull Set getKindReservedPropertyNames(Domain domain, User user, boolean forCreate)
{
return RESERVED_NAMES;
}
diff --git a/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp b/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp
index 1d316902bd2..888f2213c99 100644
--- a/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp
+++ b/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp
@@ -17,7 +17,6 @@
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="org.jetbrains.annotations.NotNull" %>
<%@ page import="org.junit.After" %>
-<%@ page import="org.junit.Assume" %>
<%@ page import="org.junit.Before" %>
<%@ page import="org.junit.Test" %>
<%@ page import="org.labkey.api.action.ApiUsageException" %>
@@ -67,8 +66,6 @@
<%@ page import="org.labkey.api.gwt.client.model.GWTDomain" %>
<%@ page import="org.labkey.api.gwt.client.model.GWTIndex" %>
<%@ page import="org.labkey.api.gwt.client.model.GWTPropertyDescriptor" %>
-<%@ page import="org.labkey.api.module.Module" %>
-<%@ page import="org.labkey.api.module.ModuleLoader" %>
<%@ page import="org.labkey.api.query.BatchValidationException" %>
<%@ page import="org.labkey.api.query.DefaultSchema" %>
<%@ page import="org.labkey.api.query.FieldKey" %>
@@ -95,7 +92,6 @@
<%@ page import="org.labkey.remoteapi.query.SelectRowsResponse" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.util.ArrayList" %>
-<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.HashSet" %>
@@ -110,43 +106,52 @@
<%@ page import="static org.labkey.api.util.IntegerUtils.asInteger" %>
<%@ page import="static org.labkey.api.util.IntegerUtils.asLong" %>
<%@ page import="static org.hamcrest.Matchers.containsString" %>
+<%@ page import="org.junit.BeforeClass" %>
+<%@ page import="org.junit.AfterClass" %>
<%@ page extends="org.labkey.api.jsp.JspTest.BVT" %>
<%!
+static final String PROJECT_NAME = "_testDataClass";
ExpProvisionedTableTestHelper helper = new ExpProvisionedTableTestHelper();
Container c;
+static User _user;
+
+@BeforeClass
+public static void setUp()
+{
+ _user = TestContext.get().getUser();
+}
@Before
-public void setUp()
+public void ensureProject()
{
- // NOTE: We need to use a project to create the DataClass so we can insert rows into sub-folders
- c = ContainerManager.getForPath("_testDataClass");
- if (c != null)
- ContainerManager.deleteAll(c, TestContext.get().getUser());
- c = ContainerManager.createContainer(ContainerManager.getRoot(), "_testDataClass", TestContext.get().getUser());
+ // Some tests delete the project so ensure it is available for the next test
+ c = ContainerManager.ensureContainer(PROJECT_NAME, _user);
}
@After
-public void tearDown() throws InterruptedException
+public void drainQueue() throws InterruptedException
{
// Wait for the indexer to finish working on the data we just added to help avoid deadlocks
SearchService.get().drainQueue(SearchService.PRIORITY.crawl, 15, TimeUnit.SECONDS);
- ContainerManager.deleteAll(c, TestContext.get().getUser());
}
+@AfterClass
+public static void tearDown()
+{
+ Container project = ContainerManager.getForPath(PROJECT_NAME);
+ if (project != null)
+ ContainerManager.deleteAll(project, _user);
+}
// validate name is not null
@Test
public void nameNotNull() throws Exception
{
- final User user = TestContext.get().getUser();
-
try
{
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("foo", "string"));
-
- ExperimentServiceImpl.get().createDataClass(c, user, null, null, props, emptyList(), null, null);
+ List props = List.of(new GWTPropertyDescriptor("foo", "string"));
+ ExperimentServiceImpl.get().createDataClass(c, _user, null, null, props, emptyList(), null, null);
}
catch (ApiUsageException e)
{
@@ -157,14 +162,10 @@ public void nameNotNull() throws Exception
@Test // Issue 51321
public void reservedNameFirst() throws Exception
{
- final User user = TestContext.get().getUser();
-
try
{
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("foo", "string"));
-
- ExperimentServiceImpl.get().createDataClass(c, user, "First", null, props, emptyList(), null, null);
+ List props = List.of(new GWTPropertyDescriptor("foo", "string"));
+ ExperimentServiceImpl.get().createDataClass(c, _user, "First", null, props, emptyList(), null, null);
}
catch (ApiUsageException e)
{
@@ -175,14 +176,10 @@ public void reservedNameFirst() throws Exception
@Test // Issue 51321
public void reservedNameAll() throws Exception
{
- final User user = TestContext.get().getUser();
-
try
{
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("foo", "string"));
-
- ExperimentServiceImpl.get().createDataClass(c, user, "All", null, props, emptyList(), null, null);
+ List props = List.of(new GWTPropertyDescriptor("foo", "string"));
+ ExperimentServiceImpl.get().createDataClass(c, _user, "All", null, props, emptyList(), null, null);
}
catch (ApiUsageException e)
{
@@ -194,15 +191,11 @@ public void reservedNameAll() throws Exception
@Test
public void nameScale() throws Exception
{
- final User user = TestContext.get().getUser();
-
try
{
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("foo", "string"));
-
+ List props = List.of(new GWTPropertyDescriptor("foo", "string"));
String name = StringUtils.repeat("a", 1000);
- ExperimentServiceImpl.get().createDataClass(c, user, name, null, props, emptyList(), null, null);
+ ExperimentServiceImpl.get().createDataClass(c, _user, name, null, props, emptyList(), null, null);
}
catch (ApiUsageException e)
{
@@ -214,17 +207,12 @@ public void nameScale() throws Exception
@Test
public void nameExpressionScale() throws Exception
{
- final User user = TestContext.get().getUser();
-
try
{
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("foo", "string"));
-
+ List props = List.of(new GWTPropertyDescriptor("foo", "string"));
DataClassDomainKindProperties options = new DataClassDomainKindProperties();
options.setNameExpression(StringUtils.repeat("a", 1000));
-
- ExperimentServiceImpl.get().createDataClass(c, user, "testing", options, props, emptyList(), null, null);
+ ExperimentServiceImpl.get().createDataClass(c, _user, "testing", options, props, emptyList(), null, null);
}
catch (ApiUsageException e)
{
@@ -232,25 +220,21 @@ public void nameExpressionScale() throws Exception
}
}
-
@Test
public void testDataClass() throws Exception
{
- final User user = TestContext.get().getUser();
- final Container sub = ContainerManager.createContainer(c, "sub", TestContext.get().getUser());
+ final Container sub = ContainerManager.createContainer(c, "subTestDataClass", _user);
final String dataClassName = "testing";
- List props = new ArrayList<>();
- props.add(new GWTPropertyDescriptor("aa", "int"));
- props.add(new GWTPropertyDescriptor("bb", "string"));
-
- List indices = new ArrayList<>();
- indices.add(new GWTIndex(Arrays.asList("aa"), true));
-
+ List props = List.of(
+ new GWTPropertyDescriptor("aa", "int"),
+ new GWTPropertyDescriptor("bb", "string")
+ );
+ List indices = List.of(new GWTIndex(List.of("aa"), true));
DataClassDomainKindProperties options = new DataClassDomainKindProperties();
options.setNameExpression("JUNIT-${genId}-${aa}");
- final ExpDataClassImpl dataClass = ExperimentServiceImpl.get().createDataClass(c, user, dataClassName, options, props, indices, null, null);
+ final ExpDataClassImpl dataClass = ExperimentServiceImpl.get().createDataClass(c, _user, dataClassName, options, props, indices, null, null);
assertNotNull(dataClass);
final Domain domain = dataClass.getDomain();
@@ -263,20 +247,16 @@ public void testDataClass() throws Exception
String expectedSubName = "JUNIT-3-30";
testInsertIntoSubfolder(dataClass, table, sub, expectedSubName);
testTruncateRows(dataClass, table, expectedName, expectedSubName);
- testBulkImport(dataClass, table, user);
- testInsertAliases(dataClass, table);
- testEmptyInsert(dataClass, table, user);
- testDeleteExpData(dataClass, user, 3);
- testDeleteExpDataClass(dataClass, user, table, domain.getTypeURI());
+ testBulkImport(dataClass, table);
+ testInsertAliases(table);
+ testEmptyInsert(table, _user);
+ testDeleteExpData(dataClass, _user, 3);
+ testDeleteExpDataClass(dataClass, _user, table, domain.getTypeURI());
}
private void testNameExpressionGeneration(ExpDataClassImpl dataClass, TableInfo table, String expectedName) throws Exception
{
- List