|
43 | 43 | import static org.hamcrest.MatcherAssert.assertThat; |
44 | 44 | import static org.junit.Assert.assertEquals; |
45 | 45 | import static org.labkey.test.util.TestDataGenerator.randomDomainName; |
46 | | -import static org.labkey.test.util.TestDataGenerator.randomFieldName; |
47 | 46 |
|
48 | 47 | @Category({Daily.class}) |
49 | 48 | public class EditableGridTest extends BaseWebDriverTest |
50 | 49 | { |
51 | 50 | private static final String EXTRAPOLATING_SAMPLE_TYPE = randomDomainName("ExtrapolatingSampleType"); |
52 | | - private static final String ASC_STRING = randomFieldName("Ascending String"); |
53 | | - private static final String DESC_STRING = randomFieldName("Descending String"); |
54 | | - private static final String ASC_INT = randomFieldName("Ascending Int"); |
55 | | - private static final String DESC_INT = randomFieldName("Descending Int"); |
56 | | - private static final String ASC_DATE = randomFieldName("Ascending Date"); |
57 | | - private static final String DESC_DATE = randomFieldName("Descending Date"); |
| 51 | + private static final FieldInfo ASC_STRING = FieldInfo.random("Ascending String"); |
| 52 | + private static final FieldInfo DESC_STRING = FieldInfo.random("Descending String"); |
| 53 | + private static final FieldInfo ASC_INT = FieldInfo.random("Ascending Int", ColumnType.Integer); |
| 54 | + private static final FieldInfo DESC_INT = FieldInfo.random("Descending Int", ColumnType.Integer); |
| 55 | + private static final FieldInfo ASC_DATE = FieldInfo.random("Ascending Date", ColumnType.DateAndTime); |
| 56 | + private static final FieldInfo DESC_DATE = FieldInfo.random("Descending Date", ColumnType.DateAndTime); |
58 | 57 |
|
59 | 58 | private static final String FILLING_SAMPLE_TYPE = randomDomainName("FillingSampleType"); |
60 | | - private static final String FILL_STRING = randomFieldName("Filling String"); |
61 | | - private static final String FILL_MULTI_LINE = randomFieldName("Filling Multi Line"); |
62 | | - private static final String FILL_INT = randomFieldName("Filling Int"); |
63 | | - private static final String FILL_DATE = randomFieldName("Filling Date"); |
| 59 | + private static final FieldInfo FILL_STRING = FieldInfo.random("Filling String"); |
| 60 | + private static final FieldInfo FILL_MULTI_LINE = FieldInfo.random("Filling Multi Line", ColumnType.MultiLine); |
| 61 | + private static final FieldInfo FILL_INT = FieldInfo.random("Filling Int", ColumnType.Integer); |
| 62 | + private static final FieldInfo FILL_DATE = FieldInfo.random("Filling Date", ColumnType.DateAndTime); |
64 | 63 |
|
65 | 64 | private static final String PASTING_SAMPLE_TYPE = randomDomainName("PastingSampleType"); |
66 | | - private static final String PASTE_1 = randomFieldName("Paste Column 1"); |
67 | | - private static final String PASTE_2 = randomFieldName("Paste Column 2"); |
68 | | - private static final String PASTE_3 = randomFieldName("Paste Column 3"); |
69 | | - private static final String PASTE_4 = randomFieldName("Paste Column 4"); |
70 | | - private static final String PASTE_5 = randomFieldName("Paste Column 5"); |
71 | | - private static final String PASTE_ML = randomFieldName("Paste Multi Line"); |
| 65 | + private static final FieldInfo PASTE_1 = FieldInfo.random("Paste Column 1"); |
| 66 | + private static final FieldInfo PASTE_2 = FieldInfo.random("Paste Column 2"); |
| 67 | + private static final FieldInfo PASTE_3 = FieldInfo.random("Paste Column 3"); |
| 68 | + private static final FieldInfo PASTE_4 = FieldInfo.random("Paste Column 4"); |
| 69 | + private static final FieldInfo PASTE_5 = FieldInfo.random("Paste Column 5"); |
| 70 | + private static final FieldInfo PASTE_ML = FieldInfo.random("Paste Multi Line", ColumnType.MultiLine); |
72 | 71 |
|
73 | 72 | private static final List<String> TEXT_CHOICES = Arrays.asList("red", "Orange", "YELLOW"); |
74 | 73 | private static final String LOOKUP_LIST = randomDomainName("Fruits"); |
75 | 74 | private static final List<String> LOOKUP_CHOICES = Arrays.asList("apple", "Orange", "kiwi"); |
76 | 75 |
|
77 | 76 | private static final String ALL_TYPE_SAMPLE_TYPE = randomDomainName("AllFieldsSampleType"); |
78 | 77 |
|
79 | | - private static final FieldInfo STR_FIELD = new FieldInfo(randomFieldName("strCol")) |
| 78 | + private static final FieldInfo STR_FIELD = FieldInfo.random("strCol") |
80 | 79 | .customizeFieldDefinition(fd -> fd.setScale(10)); |
81 | | - private static final FieldInfo REQ_STR_FIELD = new FieldInfo(randomFieldName("strColReq")) |
| 80 | + private static final FieldInfo REQ_STR_FIELD = FieldInfo.random("strColReq") |
82 | 81 | .customizeFieldDefinition(fd -> fd.setScale(10).setRequired(true)); |
83 | | - private static final FieldInfo INT_FIELD = new FieldInfo(randomFieldName("intCol"), ColumnType.Integer); |
84 | | - private static final FieldInfo REQ_INT_FIELD = new FieldInfo(randomFieldName("intColReq"), ColumnType.Integer) |
| 82 | + private static final FieldInfo INT_FIELD = FieldInfo.random("intCol", ColumnType.Integer); |
| 83 | + private static final FieldInfo REQ_INT_FIELD = FieldInfo.random("intColReq", ColumnType.Integer) |
85 | 84 | .customizeFieldDefinition(fd -> fd.setRequired(true)); |
86 | | - private static final FieldInfo DATE_FIELD = new FieldInfo(randomFieldName("dateCol"), ColumnType.Date); |
87 | | - private static final FieldInfo REQ_DATETIME_FIELD = new FieldInfo(randomFieldName("datetimeColReq"), ColumnType.DateAndTime) |
| 85 | + private static final FieldInfo DATE_FIELD = FieldInfo.random("dateCol", ColumnType.Date); |
| 86 | + private static final FieldInfo REQ_DATETIME_FIELD = FieldInfo.random("datetimeColReq", ColumnType.DateAndTime) |
88 | 87 | .customizeFieldDefinition(fd -> fd.setRequired(true)); |
89 | | - private static final FieldInfo TIME_FIELD = new FieldInfo(randomFieldName("timeCol"), ColumnType.Time); |
90 | | - private static final FieldInfo REQ_TIME_FIELD = new FieldInfo(randomFieldName("timeColReq"), ColumnType.Time) |
| 88 | + private static final FieldInfo TIME_FIELD = FieldInfo.random("timeCol", ColumnType.Time); |
| 89 | + private static final FieldInfo REQ_TIME_FIELD = FieldInfo.random("timeColReq", ColumnType.Time) |
91 | 90 | .customizeFieldDefinition(fd -> fd.setRequired(true)); |
92 | | - private static final FieldInfo BOOL_FIELD = new FieldInfo(randomFieldName("boolCol"), ColumnType.Boolean); |
93 | | - private static final FieldInfo FLOAT_FIELD = new FieldInfo(randomFieldName("floatCol"), ColumnType.Decimal); |
94 | | - private static final FieldInfo TEXTCHOICE_FIELD = new FieldInfo(randomFieldName("textchoiceCol"), ColumnType.TextChoice) |
| 91 | + private static final FieldInfo BOOL_FIELD = FieldInfo.random("boolCol", ColumnType.Boolean); |
| 92 | + private static final FieldInfo FLOAT_FIELD = FieldInfo.random("floatCol", ColumnType.Decimal); |
| 93 | + private static final FieldInfo TEXTCHOICE_FIELD = FieldInfo.random("textchoiceCol", ColumnType.TextChoice) |
95 | 94 | .customizeFieldDefinition(fd -> fd.setTextChoiceValues(TEXT_CHOICES)); |
96 | | - private static final FieldInfo REQ_TEXTCHOICE_FIELD = new FieldInfo(randomFieldName("textchoiceColReq"), ColumnType.TextChoice) |
| 95 | + private static final FieldInfo REQ_TEXTCHOICE_FIELD = FieldInfo.random("textchoiceColReq", ColumnType.TextChoice) |
97 | 96 | .customizeFieldDefinition(fd -> fd.setRequired(true).setTextChoiceValues(TEXT_CHOICES)); |
98 | | - private static final FieldInfo LOOKUP_FIELD = new FieldInfo(randomFieldName("lookupCol"), new IntLookup(null, "lists", LOOKUP_LIST)); |
99 | | - private static final FieldInfo REQ_LOOKUP_FIELD = new FieldInfo(randomFieldName("lookupColReq"), new IntLookup(null, "lists", LOOKUP_LIST)) |
| 97 | + private static final FieldInfo LOOKUP_FIELD = FieldInfo.random("lookupCol", new IntLookup(null, "lists", LOOKUP_LIST)); |
| 98 | + private static final FieldInfo REQ_LOOKUP_FIELD = FieldInfo.random("lookupColReq", new IntLookup(null, "lists", LOOKUP_LIST)) |
100 | 99 | .customizeFieldDefinition(fd -> fd.setRequired(true)); |
101 | 100 |
|
102 | 101 | final List<FieldInfo> ALL_FIELDS = Arrays.asList(STR_FIELD, REQ_STR_FIELD, INT_FIELD, REQ_INT_FIELD, |
@@ -131,32 +130,32 @@ private void doSetup() throws Exception |
131 | 130 | new SampleTypeDefinition(EXTRAPOLATING_SAMPLE_TYPE) |
132 | 131 | .setFields( |
133 | 132 | List.of( |
134 | | - new FieldDefinition(ASC_STRING, ColumnType.String), |
135 | | - new FieldDefinition(DESC_STRING, ColumnType.String), |
136 | | - new FieldDefinition(ASC_INT, ColumnType.Integer), |
137 | | - new FieldDefinition(DESC_INT, ColumnType.Integer), |
138 | | - new FieldDefinition(ASC_DATE, ColumnType.DateAndTime), |
139 | | - new FieldDefinition(DESC_DATE, ColumnType.DateAndTime) |
| 133 | + ASC_STRING.getFieldDefinition(), |
| 134 | + DESC_STRING.getFieldDefinition(), |
| 135 | + ASC_INT.getFieldDefinition(), |
| 136 | + DESC_INT.getFieldDefinition(), |
| 137 | + ASC_DATE.getFieldDefinition(), |
| 138 | + DESC_DATE.getFieldDefinition() |
140 | 139 | )) |
141 | 140 | .create(connection, getProjectName()); |
142 | 141 | new SampleTypeDefinition(FILLING_SAMPLE_TYPE) |
143 | 142 | .setFields( |
144 | 143 | List.of( |
145 | | - new FieldDefinition(FILL_STRING, ColumnType.String), |
146 | | - new FieldDefinition(FILL_MULTI_LINE, ColumnType.MultiLine), |
147 | | - new FieldDefinition(FILL_INT, ColumnType.Integer), |
148 | | - new FieldDefinition(FILL_DATE, ColumnType.DateAndTime) |
| 144 | + FILL_STRING.getFieldDefinition(), |
| 145 | + FILL_MULTI_LINE.getFieldDefinition(), |
| 146 | + FILL_INT.getFieldDefinition(), |
| 147 | + FILL_DATE.getFieldDefinition() |
149 | 148 | )) |
150 | 149 | .create(connection, getProjectName()); |
151 | 150 | new SampleTypeDefinition(PASTING_SAMPLE_TYPE) |
152 | 151 | .setFields( |
153 | 152 | List.of( |
154 | | - new FieldDefinition(PASTE_1, ColumnType.String), |
155 | | - new FieldDefinition(PASTE_2, ColumnType.String), |
156 | | - new FieldDefinition(PASTE_3, ColumnType.String), |
157 | | - new FieldDefinition(PASTE_4, ColumnType.String), |
158 | | - new FieldDefinition(PASTE_5, ColumnType.String), |
159 | | - new FieldDefinition(PASTE_ML, ColumnType.MultiLine) |
| 153 | + PASTE_1.getFieldDefinition(), |
| 154 | + PASTE_2.getFieldDefinition(), |
| 155 | + PASTE_3.getFieldDefinition(), |
| 156 | + PASTE_4.getFieldDefinition(), |
| 157 | + PASTE_5.getFieldDefinition(), |
| 158 | + PASTE_ML.getFieldDefinition() |
160 | 159 | )) |
161 | 160 | .create(connection, getProjectName()); |
162 | 161 |
|
@@ -999,8 +998,7 @@ public void testShiftArrowSelectHorizontal() |
999 | 998 | .verifyEquals("There should be no grid cells already selected. Fatal error.", |
1000 | 999 | 0, editableGrid.getSelectedCells().size()); |
1001 | 1000 |
|
1002 | | - List<String> columns = editableGrid.getColumnLabels(); |
1003 | | - int startColumn = columns.indexOf(PASTE_1); |
| 1001 | + int startColumn = editableGrid.getColumnIndex(PASTE_1); |
1004 | 1002 |
|
1005 | 1003 | int gridRow = 4; |
1006 | 1004 | WebElement startCell = editableGrid.getCell(gridRow, PASTE_1); |
@@ -1318,10 +1316,10 @@ private static String rowsToString(List<List<String>> rows) |
1318 | 1316 | .collect(Collectors.joining("\n")); |
1319 | 1317 | } |
1320 | 1318 |
|
1321 | | - private static List<WebElement> setCellValues(EditableGrid testGrid, String ascString, Object... values) |
| 1319 | + private static List<WebElement> setCellValues(EditableGrid testGrid, CharSequence columnIdentifier, Object... values) |
1322 | 1320 | { |
1323 | 1321 | List<WebElement> cells = new ArrayList<>(); |
1324 | | - List.of(values).forEach(value -> cells.add(testGrid.setCellValue(cells.size(), ascString, value))); |
| 1322 | + List.of(values).forEach(value -> cells.add(testGrid.setCellValue(cells.size(), columnIdentifier, value))); |
1325 | 1323 | return cells; |
1326 | 1324 | } |
1327 | 1325 |
|
|
0 commit comments