Skip to content

Commit fcc60fa

Browse files
Add a test to cover sample type name containing a period and used as a required parent.
Add a list of realistic domain names. Remove deprecated code. Add an isRequired parameter to EntityTypeDesigner
1 parent c502fc4 commit fcc60fa

5 files changed

Lines changed: 137 additions & 23 deletions

File tree

src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,19 @@ public List<String> getParentAliasOptions(int index)
366366
}
367367

368368
public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText)
369+
{
370+
return setParentAlias(index, alias, optionDisplayText, false);
371+
}
372+
373+
public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText, boolean isRequired)
369374
{
370375
expandPropertiesPanel();
371376
elementCache().parentAlias(index).setValue(alias);
372377
if (optionDisplayText != null)
373378
{
374379
elementCache().parentAliasSelect(index).select(optionDisplayText);
375380
}
381+
getWrapper().setCheckbox(elementCache().parentAliasRequiredCheckbox(index), isRequired);
376382
return getThis();
377383
}
378384

@@ -447,6 +453,12 @@ public Input parentAlias(int index)
447453
return parentAliases().get(index);
448454
}
449455

456+
public WebElement parentAliasRequiredCheckbox(int index)
457+
{
458+
return Locator.tagWithName("input","required").withAttribute("type", "checkbox")
459+
.findElements(propertiesPanel).get(index);
460+
}
461+
450462
public WebElement removeParentAliasIcon(int index)
451463
{
452464
return Locator.tagWithClass("span","domain-field-delete-icon").findElements(propertiesPanel).get(index);

src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public T addParentAlias(String alias)
4242
}
4343

4444
public T addParentAlias(String alias, @Nullable String optionDisplayText)
45+
{
46+
return addParentAlias(alias, optionDisplayText, false);
47+
}
48+
49+
public T addParentAlias(String alias, @Nullable String optionDisplayText, boolean isRequired)
4550
{
4651
expandPropertiesPanel();
4752

@@ -54,7 +59,7 @@ public T addParentAlias(String alias, @Nullable String optionDisplayText)
5459
{
5560
optionDisplayText = CURRENT_SAMPLE_TYPE;
5661
}
57-
setParentAlias(initialCount, alias, optionDisplayText);
62+
setParentAlias(initialCount, alias, optionDisplayText, isRequired);
5863
return getThis();
5964
}
6065

src/org/labkey/test/tests/SampleTypeNameExpressionTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,17 +580,14 @@ private void verifyNames(String sampleTypeName, String header, String nameExpres
580580
public void testDeriveSampleFromSampleDetailsPage() throws Exception
581581
{
582582

583-
// This test exposes Issue 44760. The issue is not caused by using the UI but rather by the latest lineage lookup
584-
// name expression feature.
585583
goToProjectHome();
586584

587585
SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
588586

589587
final String sampleType = "DerivedUI_SampleType";
588+
// Covers Issue 44760
590589
final String nameExpression = String.format("DUI_${genId}_${materialInputs/%s/Str}", PARENT_SAMPLE_TYPE_INPUT);
591590

592-
// TODO: When Issue 44760 this test can be updated to use a parent alias in the name expression.
593-
594591
log(String.format("Create a sample type named '%s' with a name expression of '%s'.", sampleType, nameExpression));
595592

596593
CreateSampleTypePage createPage = sampleHelper.goToCreateNewSampleType();
@@ -614,6 +611,7 @@ public void testDeriveSampleFromSampleDetailsPage() throws Exception
614611
checker().verifyTrue(String.format("Doesn't look like there is a link to the parent sample '%s'.", PARENT_SAMPLE_01),
615612
isElementPresent(Locator.linkWithText(PARENT_SAMPLE_01)));
616613

614+
// Covers Issue 44760
617615
final String ancestorNameExpression = String.format("GrandChild_${MaterialInputs/%s/..[MaterialInputs/%s]/Str}_${genId}", sampleType, PARENT_SAMPLE_TYPE_INPUT);
618616
log("Change the sample type name expression to support grandparent property lookup: " + ancestorNameExpression);
619617
goToProjectHome();
@@ -659,7 +657,7 @@ public void testDeriveSampleFromSampleDetailsPage() throws Exception
659657
private String deriveSample(String parentSampleName, String parentSampleType, String targetSampleType, String strVal, String intVal) throws IOException, CommandException
660658
{
661659
log(String.format("Go to the 'overview' page for sample '%s' in sample type '%s'", parentSampleName, parentSampleType));
662-
Integer sampleRowNum = SampleTypeAPIHelper.getSampleIdFromName(getProjectName(), parentSampleType, Arrays.asList(parentSampleName)).get(parentSampleName);
660+
Integer sampleRowNum = SampleTypeAPIHelper.getRowIdsForSamples(getProjectName(), parentSampleType, Arrays.asList(parentSampleName)).get(parentSampleName);
663661

664662
String url = WebTestHelper.buildRelativeUrl("experiment", getCurrentContainerPath(), "showMaterial", Map.of("rowId", sampleRowNum));
665663
beginAt(url);

src/org/labkey/test/util/data/TestDataUtils.java

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,123 @@ public class TestDataUtils
134134
"CIS43LS ABCD PK Pre-Qual Run 3"
135135
);
136136

137+
public static final List<String> REALISTIC_DOMAIN_NAMES = List.of(
138+
"10 minute placenta",
139+
"30 minute placenta",
140+
"Adiponectin ELISA Data Fields",
141+
"Aqueous",
142+
"Ascitic fluid",
143+
"Biopsy tissue",
144+
"Buccal swabs",
145+
"Buffy coat",
146+
"DSX Study",
147+
"Cell-free DNA (cfDNA) and circulating tumor DNA (ctDNA) from plasma",
148+
"Cerebrospinal fluid (CSF)",
149+
"cfDNA",
150+
"Chemical compounds-Solid powders",
151+
"Circulating tumor cells (CTCs)",
152+
"circulating tumor DNA (ctDNA) from plasma",
153+
"Cord blood heparin",
154+
"cord.blood.heparin",
155+
"Cord DNA",
156+
"cord.DNA",
157+
"CRC_IV st_MMR",
158+
"CSF",
159+
"CTC",
160+
"ctDNA",
161+
"Cultured Cell Lines",
162+
"Cytokine ELISA Data Fields",
163+
"D2G Oncology",
164+
"2O18 Data Fields",
165+
"NA",
166+
"External Development",
167+
"External Fixed Cells (Haematology)",
168+
"FFPE - Blocks",
169+
"FFPE",
170+
"Formalin-fixed paraffin-embedded (FFPE) tissue",
171+
"Fresh frozen tissue",
172+
"Gastric_MMR",
173+
"Gastrointestinal fluid (GI)",
174+
"GI",
175+
"In House Fixed Cells (Haematology)",
176+
"Insulin ELISA Data Fields",
177+
"Juul",
178+
"Kindeva",
179+
"Leptin ELISA Data Fields",
180+
"LOY-001 PK Data Fields",
181+
"Maternal DNA",
182+
"Membrane",
183+
"Microbiome",
184+
"Molecular&other testing",
185+
"Multiple Pathogen",
186+
"mRNA",
187+
"miRNA",
188+
"NEFA Data Fields",
189+
"Nonn Primers",
190+
"Organoids",
191+
"Paternal DNA",
192+
"PAXGENE",
193+
"PBMC",
194+
"Peripheral blood mononuclear cells",
195+
"Placenta DNA",
196+
"Placenta RNA",
197+
"Plasma",
198+
"Platelet count",
199+
"Primary Cells",
200+
"Primary Cells from Tumor Tissue",
201+
"Primes",
202+
"PTSD",
203+
"Recode Therapeutics",
204+
"Research Development",
205+
"Research Project",
206+
"Retrospective archive_FFPE",
207+
"RNA",
208+
"Saliva swabs",
209+
"Sample release",
210+
"Samples created for V&V studies",
211+
"Serum",
212+
"Studies",
213+
"Study",
214+
"Surgical resection specimens",
215+
"TFF pharmaceuticals",
216+
"Trizol",
217+
"Truvian Sciences",
218+
"TSS",
219+
"Urine",
220+
"Virome",
221+
"Vitreous",
222+
"Water Stock",
223+
"Whole Blood",
224+
"Whole Globe"
225+
);
226+
137227
private TestDataUtils()
138228
{
139229
// Utility class. Do not instantiate.
140230
}
141231

142232
public static String getRealisticPlateName()
143233
{
144-
return REALISTIC_PLATE_NAMES.get(TestDataGenerator.randomInt(0, REALISTIC_PLATE_NAMES.size() - 1));
234+
return getRealisticPlateName(new ArrayList<>());
235+
}
236+
237+
public static String getRealisticPlateName(List<String> excludePlateNames)
238+
{
239+
List<String> includeNames = new ArrayList<>(REALISTIC_PLATE_NAMES);
240+
includeNames.removeAll(excludePlateNames);
241+
return includeNames.get(TestDataGenerator.randomInt(0, includeNames.size() - 1));
242+
}
243+
244+
public static String getRealisticDomainName()
245+
{
246+
return getRealisticDomainName(new ArrayList<>());
247+
}
248+
249+
public static String getRealisticDomainName(List<String> excludeDomains)
250+
{
251+
List<String> includeNames = new ArrayList<>(REALISTIC_DOMAIN_NAMES);
252+
includeNames.removeAll(excludeDomains);
253+
return includeNames.get(TestDataGenerator.randomInt(0, includeNames.size() - 1));
145254
}
146255

147256
public static List<Map<String, Object>> rowMapsFromTsv(File tsvFile) throws IOException

src/org/labkey/test/util/exp/SampleTypeAPIHelper.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public static TestDataGenerator createEmptySampleType(String containerPath, Samp
5858
public static List<FieldDefinition> sampleTypeTestFields(boolean withFileField)
5959
{
6060
List<FieldDefinition> fields = new ArrayList<>(Arrays.asList(
61-
new FieldDefinition("intColumn", FieldDefinition.ColumnType.Integer),
62-
new FieldDefinition("decimalColumn", FieldDefinition.ColumnType.Decimal),
63-
new FieldDefinition("stringColumn", FieldDefinition.ColumnType.String),
64-
new FieldDefinition("sampleDate", FieldDefinition.ColumnType.DateAndTime),
65-
new FieldDefinition("boolColumn", FieldDefinition.ColumnType.Boolean)));
61+
new FieldDefinition(TestDataGenerator.randomFieldName("intColumn"), FieldDefinition.ColumnType.Integer),
62+
new FieldDefinition(TestDataGenerator.randomFieldName("decimalColumn"), FieldDefinition.ColumnType.Decimal),
63+
new FieldDefinition(TestDataGenerator.randomFieldName("stringColumn"), FieldDefinition.ColumnType.String),
64+
new FieldDefinition(TestDataGenerator.randomFieldName("sampleDate"), FieldDefinition.ColumnType.DateAndTime),
65+
new FieldDefinition(TestDataGenerator.randomFieldName("boolColumn"), FieldDefinition.ColumnType.Boolean)));
6666
if (withFileField)
67-
fields.add(new FieldDefinition("fileColumn", FieldDefinition.ColumnType.File));
67+
fields.add(new FieldDefinition(TestDataGenerator.randomFieldName("fileColumn"), FieldDefinition.ColumnType.File));
6868
return fields;
6969
}
7070

@@ -176,14 +176,4 @@ public static Map<String, Integer> getRowIdsForSamples(String containerPath, Str
176176
return rowIds;
177177
}
178178

179-
/**
180-
* This method has a misleading name. "Name" and "Sample ID" refer to the same column. This is actually fetching
181-
* row IDs of the specified samples.
182-
* @deprecated Use {@link #getRowIdsForSamples(String, String, List)}
183-
*/
184-
@Deprecated(since = "22.4")
185-
public static Map<String, Integer> getSampleIdFromName(String folder, String sampleTypeName, List<String> sampleNames) throws IOException, CommandException
186-
{
187-
return getRowIdsForSamples(folder, sampleTypeName, sampleNames);
188-
}
189179
}

0 commit comments

Comments
 (0)