Skip to content

Commit 917e33e

Browse files
committed
FieldDefinition and FieldInfo to keep track of namePart when randomFieldName is used
1 parent 9fa5963 commit 917e33e

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/org/labkey/test/params/FieldDefinition.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class FieldDefinition extends PropertyDescriptor
5858
// Collection of JSON properties not explicitly known by 'PropertyDescriptor'
5959
private final Map<String, Object> _extraFieldProperties = new HashMap<>();
6060

61+
private String _namePart;
62+
6163
/**
6264
* Define a non-lookup field of the specified type
6365
* @param name field name
@@ -467,6 +469,16 @@ public void setAliquotOption(ExpSchema.DerivationDataScopeType aliquotOption)
467469
_aliquotOption = aliquotOption;
468470
}
469471

472+
public void setNamePart(String namePart)
473+
{
474+
_namePart = namePart;
475+
}
476+
477+
public boolean isNamePartMatch(String namePart)
478+
{
479+
return _namePart != null && _namePart.equals(namePart);
480+
}
481+
470482
public enum RangeType
471483
{
472484
Equals("Equals", Filter.Operator.EQUAL),

src/org/labkey/test/params/FieldInfo.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class FieldInfo implements CharSequence, WrapsFieldKey
2020
private final String _label;
2121
private final ColumnType _columnType;
2222
private final Consumer<FieldDefinition> _fieldDefinitionMutator;
23+
private String _namePart; // used for random field generation to track the name part used
2324

2425
private FieldInfo(FieldKey fieldKey, String label, ColumnType columnType, Consumer<FieldDefinition> fieldDefinitionMutator)
2526
{
@@ -54,7 +55,9 @@ public FieldInfo(String name)
5455
*/
5556
public static FieldInfo random(String namePart, ColumnType columnType)
5657
{
57-
return new FieldInfo(TestDataGenerator.randomFieldName(namePart), columnType);
58+
FieldInfo field = new FieldInfo(TestDataGenerator.randomFieldName(namePart), columnType);
59+
field.setNamePart(namePart);
60+
return field;
5861
}
5962

6063
/**
@@ -165,9 +168,18 @@ private FieldDefinition getFieldDefinition(ColumnType columnType)
165168
{
166169
_fieldDefinitionMutator.accept(fieldDefinition);
167170
}
171+
if (_namePart != null)
172+
{
173+
fieldDefinition.setNamePart(_namePart);
174+
}
168175
return fieldDefinition;
169176
}
170177

178+
private void setNamePart(String namePart)
179+
{
180+
_namePart = namePart;
181+
}
182+
171183
@Override
172184
public int length()
173185
{

0 commit comments

Comments
 (0)