Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using deprecated GetDomainCommand #1785

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 47 additions & 24 deletions src/org/labkey/test/tests/DomainDesignerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.domain.ConditionalFormat;
import org.labkey.remoteapi.domain.ConditionalFormatFilter;
import org.labkey.remoteapi.domain.Domain;
import org.labkey.remoteapi.domain.DomainDetailsResponse;
import org.labkey.remoteapi.domain.DomainResponse;
import org.labkey.remoteapi.domain.GetDomainCommand;
import org.labkey.remoteapi.domain.GetDomainDetailsCommand;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.remoteapi.query.Filter;
import org.labkey.remoteapi.query.SaveRowsResponse;
Expand Down Expand Up @@ -227,8 +229,8 @@ public void testDeleteDomainField() throws Exception
.clickRemoveField(true);
domainDesignerPage.clickFinish();

GetDomainCommand domainCommand = new GetDomainCommand("exp.materials", sampleType);
DomainResponse afterResponse = domainCommand.execute(createDefaultConnection(), getProjectName());
GetDomainDetailsCommand domainCommand = new GetDomainDetailsCommand("exp.materials", sampleType);
DomainDetailsResponse afterResponse = domainCommand.execute(createDefaultConnection(), getProjectName());
Domain domain = afterResponse.getDomain();
assertEquals("expect only field in the domain to have been deleted", 0, domain.getFields().size());

Expand Down Expand Up @@ -781,7 +783,8 @@ public void setPhiLevel() throws Exception
clickAndWait(Locator.linkWithText(sampleType));

DataRegionTable sampleTypeTable = DataRegionTable.findDataRegionWithinWebpart(this, "Sample Type Contents");
DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();

assertEquals("NotPHI", getColumn(domainResponse.getDomain(), "notPHI").getPHI());
assertEquals("Limited", getColumn(domainResponse.getDomain(), "limitedPHI").getPHI());
Expand Down Expand Up @@ -813,7 +816,8 @@ public void setMissingValue() throws Exception
extraFieldRow.setMissingValuesEnabled(false);

domainDesignerPage.clickFinish();
DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
assertEquals("expect column to have MissingValue enabled", true, getColumn(domainResponse.getDomain(), "missingValue").getAllProperties().get("mvEnabled"));
assertEquals("expect column not to have MissingValue enabled", false, getColumn(domainResponse.getDomain(), "extraField").getAllProperties().get("mvEnabled"));
}
Expand Down Expand Up @@ -841,7 +845,8 @@ public void setFieldAsDimension() throws Exception

domainDesignerPage.clickFinish();

DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
assertEquals("dimensionField should have dimension marked true", true, getColumn(domainResponse.getDomain(), "dimensionField").getDimension());
assertEquals("extraField should not have dimension marked true", false, getColumn(domainResponse.getDomain(), "extraField").getDimension());
}
Expand Down Expand Up @@ -869,7 +874,8 @@ public void setFieldAsMeasure() throws Exception

domainDesignerPage.clickFinish();

DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();

assertEquals("measureField should have dimension marked true", true, getColumn(domainResponse.getDomain(), "measureField").getMeasure());
assertEquals("extraField should not have dimension marked true", false, getColumn(domainResponse.getDomain(), "extraField").getMeasure());
Expand Down Expand Up @@ -898,7 +904,8 @@ public void setFieldAsVariable() throws Exception

domainDesignerPage.clickFinish();

DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
assertEquals("variableField should have recommendedVariable marked true", true, getColumn(domainResponse.getDomain(), "variableField").getAllProperties().get("recommendedVariable"));
assertEquals("extraField should not have recommendedVariable marked true", false, getColumn(domainResponse.getDomain(), "extraField").getAllProperties().get("recommendedVariable"));
}
Expand Down Expand Up @@ -940,7 +947,8 @@ public void testLookUpFieldSampleType() throws IOException, CommandException

domainDesignerPage.clickFinish();

DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor lookupFieldDescriptor = getColumn(domainResponse.getDomain(), "lookUpField");
assertEquals("lookUpField from folder is incorrect", null, lookupFieldDescriptor.getAllProperties().get("lookupContainer"));
assertEquals("lookUpField schema name is incorrect", "lists", lookupFieldDescriptor.getAllProperties().get("lookupSchema"));
Expand Down Expand Up @@ -983,7 +991,8 @@ public void testLookUpFieldList() throws IOException, CommandException
assertEquals("Incorrect detail message", "New Field. Current Folder > lists > lookUpList", lookUpRow.detailsMessage());
domainDesignerPage.clickFinish();

DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor lookupColumn = getColumn(domainResponse.getDomain(), "lookUpField"); // getColumn asserts the column is non-null

assertEquals("lookUpField schema name should be present", "lists", lookupColumn.getAllProperties().get("lookupSchema"));
Expand Down Expand Up @@ -1028,7 +1037,8 @@ public void testLookupPropertyValidator() throws Exception
domainDesignerPage.clickFinish();

// now make sure the validator is set
DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor lookupColumn = getColumn(domainResponse.getDomain(), "looky");
Map<String, Object> propertyValidator = getPropertyValidator(lookupColumn, "Lookup Validator");
}
Expand All @@ -1054,7 +1064,8 @@ public void testDefaultValues() throws Exception
domainDesignerPage.clickFinish();

// now make sure the validator is not yet set
DomainResponse domainResponse = dgen.getDomain(createDefaultConnection());
Connection cn1 = createDefaultConnection();
DomainDetailsResponse domainResponse = dgen.getQueryHelper(cn1).getDomainDetails();
PropertyDescriptor colorCol = getColumn(domainResponse.getDomain(), "color");
assertNull("expect default value to not be set yet", colorCol.getAllProperties().get("defaultValue"));

Expand All @@ -1067,7 +1078,8 @@ public void testDefaultValues() throws Exception
setFormElement(Locator.input("color"), "green");
clickButton("Save Defaults");

DomainResponse updatedResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse updatedResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor updatedColor = getColumn(updatedResponse.getDomain(), "color");
assertEquals("expect default value to be green", "green", updatedColor.getAllProperties().get("defaultValue"));
}
Expand Down Expand Up @@ -1120,7 +1132,8 @@ public void verifyExpectedWarningOnNavigateWithUncomittedChanges() throws Except

domainDesignerPage.clickCancelWithUnsavedChanges().saveChanges(); // this should save the changes

DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn).getDomainDetails();

PropertyDescriptor faveSnackRow = getColumn(response.getDomain(), "favoriteSnack");
PropertyDescriptor newFieldRow = getColumn(response.getDomain(), "newField");
Expand Down Expand Up @@ -1201,7 +1214,8 @@ public void testMarkFieldRequired() throws Exception
.setRequiredField(true);
domainDesignerPage.clickFinish();

DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor manufacturerRow = getColumn(response.getDomain(), "manufacturer");
assertEquals("expect row to be marked 'required'", true, manufacturerRow.getRequired());
}
Expand Down Expand Up @@ -1258,7 +1272,8 @@ public void testRangeValidator() throws Exception
domainDesignerPage.clickFinish();

// now verify the expected validator is formed and added to the field's validator array
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor sizeCol = getColumn(response.getDomain(), "size");
Map<String, Object> validator = getPropertyValidator(sizeCol, "midsize");
assertEquals("expect expression to be ", "~gte=2&~lte=3", validator.get("expression"));
Expand Down Expand Up @@ -1299,7 +1314,8 @@ public void testConditionalFormat() throws Exception
domainDesignerPage.clickFinish();

// now verify the expected validator is formed and added to the field's validator array
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor faveSnackCol = getColumn(response.getDomain(), "favoriteSnack");
Map<String, Object> validator = getConditionalFormats(faveSnackCol, "format.column~doesnotcontain=almond");
assertEquals("expect italics to be set", true, validator.get("italic"));
Expand Down Expand Up @@ -1336,7 +1352,8 @@ public void testRegexValidator() throws Exception
domainDesignerPage.clickFinish();

// now verify the expected validator is formed and added to the field's validator array
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor faveSnackCol = getColumn(response.getDomain(), "favoriteSnack");
Map<String, Object> specialCharsValidator = getPropertyValidator(faveSnackCol, "neverTwizzlers");
assertEquals("validator we just created should be new", true, specialCharsValidator.get("new"));
Expand Down Expand Up @@ -1389,7 +1406,8 @@ public void addUpdateRemoveRegexValidator() throws Exception
domainDesignerPage.clickFinish();

// now verify the expected validator is formed and added to the field's validator array
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn1 = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn1).getDomainDetails();
PropertyDescriptor faveSnackCol = getColumn(response.getDomain(), "favoriteSnack");
Map<String, Object> specialCharsValidator = getPropertyValidator(faveSnackCol, "specialChars");
assertEquals("validator we just created should be new", true, specialCharsValidator.get("new"));
Expand All @@ -1416,7 +1434,8 @@ public void addUpdateRemoveRegexValidator() throws Exception
DataRegionTable.DataRegion(getDriver()).withName("query").waitFor();

// now confirm 2 validators on the field
DomainResponse newResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse newResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor snackField = getColumn(newResponse.getDomain(), "favoriteSnack");
List<Map<String, Object>> validators = (List<Map<String, Object>>) snackField.getAllProperties().get("propertyValidators");

Expand Down Expand Up @@ -1464,7 +1483,8 @@ public void addUpdateRemoveRangeValidator() throws Exception
domainDesignerPage.clickFinish();

// now verify we have 3 formats on the size field
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn1 = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn1).getDomainDetails();
PropertyDescriptor sizeCol = getColumn(response.getDomain(), "size");
Map<String, Object> lte2 = getPropertyValidator(sizeCol, "lte2");
Map<String, Object> equals3 = getPropertyValidator(sizeCol, "equals3");
Expand All @@ -1487,7 +1507,8 @@ public void addUpdateRemoveRangeValidator() throws Exception
DataRegionTable.DataRegion(getDriver()).withName("query").waitFor();

// now verify we have 2 formats on the size field
DomainResponse updatedResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse updatedResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor updatedSizeCol = getColumn(updatedResponse.getDomain(), "size");
List<Map<String, Object>> validators = (List<Map<String, Object>>) updatedSizeCol.getAllProperties().get("propertyValidators");
assertEquals("expect only 2 validators on the field", 2, validators.size());
Expand Down Expand Up @@ -1530,7 +1551,8 @@ public void addUpdateRemoveConditionalFormat() throws Exception
domainDesignerPage.clickFinish();

// now verify we have 3
DomainResponse response = dgen.getDomain(createDefaultConnection());
Connection cn1 = createDefaultConnection();
DomainDetailsResponse response = dgen.getQueryHelper(cn1).getDomainDetails();
PropertyDescriptor heroCol = getColumn(response.getDomain(), "superHero");
Map<String, Object> thorMap = getConditionalFormats(heroCol, "format.column~eq=Thor");
Map<String, Object> aquaMap = getConditionalFormats(heroCol, "format.column~eq=Aquaman");
Expand All @@ -1549,7 +1571,8 @@ public void addUpdateRemoveConditionalFormat() throws Exception
dlg.clickApply();
domainDesignerPage.clickFinish();

DomainResponse validationResponse = dgen.getDomain(createDefaultConnection());
Connection cn = createDefaultConnection();
DomainDetailsResponse validationResponse = dgen.getQueryHelper(cn).getDomainDetails();
PropertyDescriptor editedHeroCol = getColumn(validationResponse.getDomain(), "superHero");

List<Map<String, Object>> formats = (List<Map<String, Object>>) editedHeroCol.getAllProperties().get("conditionalFormats");
Expand Down
9 changes: 5 additions & 4 deletions src/org/labkey/test/tests/JavaClientApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.domain.CreateDomainCommand;
import org.labkey.remoteapi.domain.Domain;
import org.labkey.remoteapi.domain.DomainDetailsResponse;
import org.labkey.remoteapi.domain.DomainResponse;
import org.labkey.remoteapi.domain.DropDomainCommand;
import org.labkey.remoteapi.domain.GetDomainCommand;
import org.labkey.remoteapi.domain.GetDomainDetailsCommand;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.remoteapi.domain.SaveDomainCommand;
import org.labkey.remoteapi.query.DeleteRowsCommand;
Expand Down Expand Up @@ -357,9 +358,9 @@ public void doDomainTest() throws Exception
Set<String> expected = new HashSet<>(Arrays.asList("key", "foo", "bar", "baz"));
verifyDomain(response.getDomain(), expected);

GetDomainCommand getCmd = new GetDomainCommand("lists", LIST_NAME);
response = getCmd.execute(cn, PROJECT_NAME);
verifyDomain(response.getDomain(), expected);
GetDomainDetailsCommand getCmd = new GetDomainDetailsCommand("lists", LIST_NAME);
DomainDetailsResponse detailsResponse = getCmd.execute(cn, PROJECT_NAME);
verifyDomain(detailsResponse.getDomain(), expected);

log("modify the existing domain");
SaveDomainCommand saveCmd = new SaveDomainCommand("lists", LIST_NAME);
Expand Down
8 changes: 4 additions & 4 deletions src/org/labkey/test/tests/issues/IssueDomainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.junit.experimental.categories.Category;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.domain.Domain;
import org.labkey.remoteapi.domain.DomainResponse;
import org.labkey.remoteapi.domain.GetDomainCommand;
import org.labkey.remoteapi.domain.DomainDetailsResponse;
import org.labkey.remoteapi.domain.GetDomainDetailsCommand;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.remoteapi.domain.SaveDomainCommand;
import org.labkey.test.BaseWebDriverTest;
Expand Down Expand Up @@ -88,8 +88,8 @@ public void mandatoryFieldTest() throws Exception
List<String> mandatoryFields = Arrays.asList("title", "notifylist", "assignedto", "resolution");
for (String mandatoryField : mandatoryFields)
{
GetDomainCommand getCmd = new GetDomainCommand(DOMAIN_NAME, ISSUES_NAME);
DomainResponse getDomainResponse = getCmd.execute(this.createDefaultConnection(), getContainerPath());
GetDomainDetailsCommand getCmd = new GetDomainDetailsCommand(DOMAIN_NAME, ISSUES_NAME);
DomainDetailsResponse getDomainResponse = getCmd.execute(this.createDefaultConnection(), getContainerPath());
List<PropertyDescriptor> getDomainCols = getDomainResponse.getDomain().getFields();
ListIterator<PropertyDescriptor> getDomainColsIterator = getDomainCols.listIterator();

Expand Down
7 changes: 3 additions & 4 deletions src/org/labkey/test/util/DomainUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.CommandResponse;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.domain.DomainResponse;
import org.labkey.remoteapi.domain.DropDomainCommand;
import org.labkey.remoteapi.domain.GetDomainCommand;
import org.labkey.remoteapi.domain.GetDomainDetailsCommand;
import org.labkey.test.WebTestHelper;

import java.io.IOException;
Expand Down Expand Up @@ -54,10 +53,10 @@ public static CommandResponse deleteDomain(final String containerPath, final Str
public static boolean doesDomainExist(final String containerPath, final String schema, final String queryName)
{
Connection connection = WebTestHelper.getRemoteApiConnection();
GetDomainCommand cmd = new GetDomainCommand(schema, queryName);
GetDomainDetailsCommand cmd = new GetDomainDetailsCommand(schema, queryName);
try
{
DomainResponse response = cmd.execute(connection, containerPath);
cmd.execute(connection, containerPath);
return true;
}
catch (CommandException ce)
Expand Down
10 changes: 1 addition & 9 deletions src/org/labkey/test/util/TestDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.labkey.test.TestFileUtils;
import org.labkey.test.WebTestHelper;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.list.IntListDefinition;
import org.labkey.test.util.query.QueryApiHelper;

import java.io.File;
Expand Down Expand Up @@ -423,15 +424,6 @@ public DomainResponse createList(Connection cn, String keyName) throws IOExcepti
return createDomain(cn, "IntList", Map.of("keyName", keyName));
}

/**
* @deprecated Use {@link QueryApiHelper}
*/
@Deprecated(since = "22.4")
public DomainResponse getDomain(Connection cn) throws IOException, CommandException
{
return getQueryHelper(cn).getDomain();
}

/**
* @deprecated Use {@link QueryApiHelper}
*/
Expand Down
Loading