diff --git a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
index eaef546e67..693118a774 100644
--- a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
+++ b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
@@ -46,7 +46,6 @@
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.EscapeUtil;
import org.labkey.test.util.LogMethod;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
@@ -102,12 +101,8 @@ public BrowserType bestBrowser()
protected void doCleanup(boolean afterTest)
{
super.doCleanup(afterTest);
- if (afterTest)
+ if (!afterTest)
{
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
- }
- else {
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
SampleTypeFolderExportImportTest init = getCurrentTest();
init.doSetup();
}
diff --git a/src/org/labkey/test/tests/SampleTypeLimitsTest.java b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
index 4933febe16..d01630ab3e 100644
--- a/src/org/labkey/test/tests/SampleTypeLimitsTest.java
+++ b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
@@ -15,7 +15,6 @@
*/
package org.labkey.test.tests;
-import org.jetbrains.annotations.Nullable;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -36,10 +35,10 @@
import org.labkey.test.params.list.ListDefinition;
import org.labkey.test.params.list.VarListDefinition;
import org.labkey.test.util.DataRegionTable;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
+import org.labkey.test.util.query.QueryApiHelper;
import java.io.IOException;
import java.util.Arrays;
@@ -118,13 +117,6 @@ private void doSetup()
}
}
- @Override
- protected void doCleanup(boolean afterTest)
- {
- super.doCleanup(afterTest);
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
- }
-
@Test
public void testStringLookupFields() throws IOException, CommandException
{
@@ -148,12 +140,12 @@ public void testStringLookupFields() throws IOException, CommandException
table.clickInsertNewRow();
setFormElement(Locator.name("quf_id"), "1");
setFormElement(Locator.name("quf_name"), "1");
- verifyInvalidLookupSample("quf_lookUpField", "Sample3", null);
+ verifyInvalidLookupSample("quf_lookUpField", "Sample3");
verifyValidLookupSample("quf_lookUpField", "Sample1");
log("Verifying editing list row with the sample display name");
table.clickEditRow("1");
- verifyInvalidLookupSample("quf_lookUpField", "Sample3", null);
+ verifyInvalidLookupSample("quf_lookUpField", "Sample3");
verifyValidLookupSample("quf_lookUpField", "Sample2");
log("Verifying editing list row with the sample RowId");
@@ -161,31 +153,28 @@ public void testStringLookupFields() throws IOException, CommandException
SelectRowsCommand command = new SelectRowsCommand("samples", SAMPLE_TYPE_NAME);
command.setFilters(Arrays.asList(new Filter("Name", "Sample1")));
SelectRowsResponse response = command.execute(createDefaultConnection(), getProjectName());
- verifyValidLookupSample("quf_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "query", false);
+ verifyValidLookupSample("quf_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "query");
}
- private void verifyInvalidLookupSample(String fieldName, String sampleValue, @Nullable String expectedErrorMsg)
+ private void verifyInvalidLookupSample(String fieldName, String sampleValue)
{
setFormElement(Locator.name(fieldName), sampleValue);
clickButton("Submit");
String errMsg = Locators.labkeyError.findElement(getDriver()).getText();
- assertEquals("Expected error is different", expectedErrorMsg == null ? "Could not convert value: " + sampleValue : expectedErrorMsg, errMsg);
+ assertEquals("Expected error is different", "Could not convert value: " + sampleValue, errMsg);
}
private void verifyValidLookupSample(String fieldName, String sampleValue)
{
- verifyValidLookupSample(fieldName, sampleValue, sampleValue, "query", false);
+ verifyValidLookupSample(fieldName, sampleValue, sampleValue, "query");
}
- private void verifyValidLookupSample(String fieldName, String sampleValue, String sampleDisplay, String dataRegionName, boolean navigateViaBreadcrumb)
+ private void verifyValidLookupSample(String fieldName, String sampleValue, String sampleDisplay, String dataRegionName)
{
setFormElement(Locator.name(fieldName), sampleValue);
clickButton("Submit");
- if (navigateViaBreadcrumb)
- clickAndWait(Locator.tagWithClass("ol", "breadcrumb").childTag("li").index(1).childTag("a"));
-
log("Verifying row is inserted correctly");
DataRegionTable table = DataRegionTable.DataRegion(getDriver()).withName(dataRegionName).waitFor();
assertEquals("Lookup field value is incorrect", sampleDisplay, table.getDataAsText(0, "lookUpField"));
@@ -203,48 +192,55 @@ private void insertSampleTypeRow(String regionName, String rowValue)
@Test
public void testDeriveSamplesLookupFields() throws IOException, CommandException
{
- goToProjectHome();
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
-
log("Create sample type with lookup field to " + SAMPLE_TYPE_NAME);
String sampleTypeName = "SampleTypeWithLookup";
- SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
- SampleTypeDefinition definition = new SampleTypeDefinition(sampleTypeName);
- definition.addField(new FieldDefinition("label", FieldDefinition.ColumnType.String));
- definition.addField(new FieldDefinition("lookUpField",
- new FieldDefinition.LookupInfo(null, "exp.materials", "10000Samples")
- .setTableType(FieldDefinition.ColumnType.Integer))
- .setDescription("LookUp in same container with 10000 samples"));
- sampleHelper.createSampleType(definition);
- sampleHelper.goToSampleType(sampleTypeName);
+ new SampleTypeDefinition(sampleTypeName)
+ .addField(new FieldDefinition("label", FieldDefinition.ColumnType.String))
+ .addField(new FieldDefinition("lookUpField",
+ new FieldDefinition.LookupInfo(null, "exp.materials", SAMPLE_TYPE_NAME)
+ .setTableType(FieldDefinition.ColumnType.Integer))
+ .setDescription("LookUp in same container with 10000 samples"))
+ .create(createDefaultConnection(), getProjectName());
+ QueryApiHelper queryHelper = new QueryApiHelper(createDefaultConnection(), getProjectName(), "samples", sampleTypeName);
log("Insert one sample that we can use to derive from");
- insertSampleTypeRow("Material", "Test1");
+ queryHelper.insertRows(List.of(Map.of("Name", "Test1", "label", "Test1")));
+ String parentColumn = "MaterialInputs/" + sampleTypeName;
- log("Attempt Derive Samples with invalid lookup value");
- initDeriveSamplesForm(sampleTypeName, "Derivative1");
- verifyInvalidLookupSample("Output Sample 1_lookUpField", "Sample3", "Could not convert value 'Sample3' (String) for Integer field 'lookUpField'.");
+ log("Attempt to derive a sample with invalid lookup value");
+ try
+ {
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative1", "Sample3"), true);
+ fail("Deriving a sample with an invalid lookup value should fail");
+ }
+ catch (CommandException e)
+ {
+ checker().verifyTrue("Unexpected error for invalid lookup value: " + e.getMessage(), e.getMessage().contains("Sample3"));
+ }
- log("Insert Derive Samples with valid lookup display value");
- verifyValidLookupSample("Output Sample 1_lookUpField", "Sample2", "Sample2", "Material", true);
+ log("Derive a sample with valid lookup display value");
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative1", "Sample2"), true);
- log("Insert Derive Samples with valid lookup to sample RowId");
- initDeriveSamplesForm(sampleTypeName, "Derivative2");
+ log("Derive a sample with valid lookup to sample RowId");
SelectRowsCommand command = new SelectRowsCommand("samples", SAMPLE_TYPE_NAME);
command.setFilters(Arrays.asList(new Filter("Name", "Sample1")));
SelectRowsResponse response = command.execute(createDefaultConnection(), getProjectName());
- verifyValidLookupSample("Output Sample 1_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "Material", true);
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative2", response.getRows().getFirst().get("RowId").toString()), true);
+
+ log("Verify derived samples have the expected lookup values");
+ goToProjectHome();
+ SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
+ sampleHelper.goToSampleType(sampleTypeName);
+ DataRegionTable table = sampleHelper.getSamplesDataRegionTable();
+ checker().verifyEquals("Lookup field value is incorrect", "Sample2",
+ table.getDataAsText(table.getRowIndex("Name", "Derivative1"), "lookUpField"));
+ checker().verifyEquals("Lookup field value is incorrect", "Sample1",
+ table.getDataAsText(table.getRowIndex("Name", "Derivative2"), "lookUpField"));
}
- private void initDeriveSamplesForm(String sampleTypeName, String sampleName)
+ private String deriveSampleTsv(String parentColumn, String sampleName, String lookupValue)
{
- DataRegionTable samplesTable = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor();
- samplesTable.uncheckAllOnPage();
- samplesTable.checkCheckbox(0);
- samplesTable.clickHeaderButtonAndWait("Derive Samples");
- selectOptionByText(Locator.name("targetSampleTypeId"), sampleTypeName + " in /" + getProjectName());
- clickButton("Next");
- setFormElement(Locator.name("Output Sample 1_Name"), sampleName);
+ return "Name\t" + parentColumn + "\tlookUpField\n" + sampleName + "\tTest1\t" + lookupValue + "\n";
}
@Test
diff --git a/src/org/labkey/test/tests/SampleTypeLineageTest.java b/src/org/labkey/test/tests/SampleTypeLineageTest.java
index 47dcac6485..0bf71bb341 100644
--- a/src/org/labkey/test/tests/SampleTypeLineageTest.java
+++ b/src/org/labkey/test/tests/SampleTypeLineageTest.java
@@ -29,7 +29,6 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
-import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.components.ext4.Window;
@@ -38,18 +37,17 @@
import org.labkey.test.params.experiment.DataClassDefinition;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.DataRegionTable;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
+import org.labkey.test.util.exp.SampleTypeAPIHelper;
+import org.labkey.test.util.query.QueryApiHelper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -101,15 +99,6 @@ private void doSetup()
portalHelper.addWebPart("Sample Types");
portalHelper.exitAdminMode();
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
- }
-
- @Override
- protected void doCleanup(boolean afterTest) throws TestTimeoutException
- {
- super.doCleanup(afterTest);
-
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
}
/**
@@ -215,7 +204,7 @@ public void testLineageWithParentInRootFolder()
}
@Test
- public void testSampleTypeAndLineageInSubfolder()
+ public void testSampleTypeAndLineageInSubfolder() throws IOException, CommandException
{
/*
This test will create a sample type named "ParentFolder_SampleType" in the root folder.
@@ -270,67 +259,24 @@ at ParentFolder_SampleType in the sub folder it should see one sample (the deriv
checker().wrapAssertion(()->assertTextNotPresent(parentFolderSampleType));
log("Derive two samples from the samples already present in this sample type (SubFolder_SampleType).");
- clickFolder(SUB_FOLDER_NAME);
- checker().wrapAssertion(()->assertTextPresent(subFolderSampleType, parentFolderSampleType));
-
- clickAndWait(Locator.linkWithText(subFolderSampleType));
- checkCheckbox(Locator.name(".toggle"));
- clickButton("Derive Samples");
- waitForElement(Locator.name("inputRole0"));
-
- selectOptionByText(Locator.name("inputRole0"), "Add a new role...");
- setFormElement(Locator.id("customRole0"), "FirstRole");
- selectOptionByText(Locator.name("inputRole1"), "Add a new role...");
- setFormElement(Locator.id("customRole1"), "SecondRole");
- selectOptionByText(Locator.name("inputRole2"), "Add a new role...");
- setFormElement(Locator.id("customRole2"), "ThirdRole");
- selectOptionByText(Locator.name("inputRole3"), "Add a new role...");
- setFormElement(Locator.id("customRole3"), "FourthRole");
- selectOptionByText(Locator.name("outputCount"), "2");
- selectOptionByText(Locator.name("targetSampleTypeId"), subFolderSampleType + " in /" + getProjectName() + "/" + SUB_FOLDER_NAME);
- clickButton("Next");
-
- setFormElement(Locator.name("Output Sample 1_Name"), "SampleSetBVT15");
- setFormElement(Locator.name("Output Sample 2_Name"), "SampleSetBVT16");
- checkCheckbox(Locator.name("outputSample1_IntColFolderCheckBox"));
- setFormElement(Locator.name("Output Sample 1_IntCol-Folder"), "500a");
- setFormElement(Locator.name("Output Sample 1_StringCol-Folder"), "firstOutput");
- setFormElement(Locator.name("Output Sample 2_StringCol-Folder"), "secondOutput");
- clickButton("Submit");
-
- log("Do a simple check that data validation works.");
- checker().verifyTrue("Expected error message '(String) for Integer field' is not present.",
- isTextPresent("(String) for Integer field"));
- checkCheckbox(Locator.name("outputSample1_IntColFolderCheckBox"));
- setFormElement(Locator.name("Output Sample 1_IntCol-Folder"), "500");
- clickButton("Submit");
-
- clickAndWait(Locator.linkContainingText("Derive 2 samples"));
- clickAndWait(Locator.linkContainingText("Text View"));
- assertTextPresent("FirstRole", "SecondRole", "ThirdRole", "FourthRole");
-
- log("Select one of these new derived samples and derive a sample from it");
- log("But put this new derived sample in the sample type created in the parent folder (ParentFolder_SampleType)");
- clickAndWait(Locator.linkContainingText("16"));
- clickAndWait(Locator.linkContainingText("derive samples from this sample"));
-
- selectOptionByText(Locator.name("inputRole0"), "FirstRole");
- selectOptionByText(Locator.name("targetSampleTypeId"), parentFolderSampleType + " in /" + getProjectName());
- clickButton("Next");
-
+ String subFolderPath = getProjectName() + "/" + SUB_FOLDER_NAME;
+ String grandparents = "SampleSetBVT11,SampleSetBVT4,SampleSetBVT12,SampleSetBVT13,SampleSetBVT14";
+ new QueryApiHelper(createDefaultConnection(), subFolderPath, "samples", subFolderSampleType)
+ .insertRows(List.of(
+ Map.of("Name", "SampleSetBVT15", "IntCol-Folder", 500, "StringCol-Folder", "firstOutput",
+ "MaterialInputs/" + subFolderSampleType, grandparents),
+ Map.of("Name", "SampleSetBVT16", "StringCol-Folder", "secondOutput",
+ "MaterialInputs/" + subFolderSampleType, grandparents)));
+
+ log("Derive a sample from one of these new derived samples but put it in the sample type created in the parent folder (ParentFolder_SampleType)");
String derivedSampleName = "Only_In_Sub_Folder";
- setFormElement(Locator.name("Output Sample 1_Name"), derivedSampleName);
- setFormElement(Locator.name("Output Sample 1_IntCol"), "600");
- setFormElement(Locator.name("Output Sample 1_StringCol"), "String");
- setFormElement(Locator.name("Output Sample 1_DateCol"), "BadDate");
- uncheckCheckbox(Locator.name("Output Sample 1_BoolCol"));
- clickButton("Submit");
-
- log("Again check that data validation works as expected.");
- checker().verifyTrue("Expected error message 'is not a valid Date' is not present.",
- isTextPresent(getConversionErrorMessage("BadDate", "DateCol", Date.class)));
- setFormElement(Locator.name("Output Sample 1_DateCol"), "1/1/2007");
- clickButton("Submit");
+ new QueryApiHelper(createDefaultConnection(), subFolderPath, "samples", parentFolderSampleType)
+ .insertRows(List.of(Map.of("Name", derivedSampleName, "IntCol", 600, "StringCol", "String",
+ "DateCol", "1/1/2007", "BoolCol", false,
+ "MaterialInputs/" + subFolderSampleType, "SampleSetBVT16")));
+
+ Integer derivedRowId = SampleTypeAPIHelper.getRowIdsForSamples(subFolderPath, parentFolderSampleType, List.of(derivedSampleName)).get(derivedSampleName);
+ beginAt(WebTestHelper.buildURL("experiment", subFolderPath, "showMaterial", Map.of("rowId", derivedRowId)));
log("Check that the correct sample id is shown as the parent.");
checker().verifyTrue("Link to parent sample not present.",
@@ -353,10 +299,7 @@ at ParentFolder_SampleType in the sub folder it should see one sample (the deriv
isElementPresent(Locator.linkWithText("Derive sample from SampleSetBVT16")));
checker().verifyTrue("Expected run text is not present.",
- isElementPresent(
- Locator.linkWithText("Derive 2 samples from SampleSetBVT11, SampleSetBVT12, SampleSetBVT13, SampleSetBVT14, SampleSetBVT4")
- )
- );
+ isElementPresent(Locator.linkContainingText("Derive 2 samples from ")));
log("Go to the 'SubFolder_SampleType' and make sure the expected data is there.");
clickFolder(SUB_FOLDER_NAME);
@@ -600,163 +543,6 @@ public void testDeriveSampleByImport()
assertNotEquals("RowD should not equal C", rowD.get("Run"), rowC.get("Run"));
}
- @Test
- public void testDeriveSampleByUI() throws CommandException, IOException
- {
- String sampleTypeName= "LineageUI_01";
- String namePrefix = "SampleUI-";
- int newSampleIndex = 6;
-
- goToProjectHome();
-
- log("Create a simple sample type with some samples.");
- final TestDataGenerator dgen = new SampleTypeDefinition(sampleTypeName)
- .create(createDefaultConnection(), getProjectName());
-
- for(int i = 1; i < newSampleIndex; i++)
- {
- Map