Skip to content

Commit fa61387

Browse files
committed
fix tests
1 parent 66a1464 commit fa61387

5 files changed

Lines changed: 16 additions & 40 deletions

File tree

api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,14 @@ private String withResolvedLabels(String recordMap, Container container)
251251
EXCLUDED_DETAIL_FIELDS.forEach(row::remove);
252252

253253
String statusLabel = getStatusLabel(row, container);
254-
row.put("samplestatelabel", statusLabel);
254+
if (row.containsKey("samplestate"))
255+
row.put("samplestatelabel", statusLabel);
255256

256-
String colorLabel = getColorLabel(row, container);
257-
row.put("expmaterialcolorlabel", colorLabel);
257+
if (row.containsKey(ExpMaterialColor.name()))
258+
{
259+
String colorLabel = getColorLabel(row, container);
260+
row.put("expmaterialcolorlabel", colorLabel);
261+
}
258262

259263
return AbstractAuditTypeProvider.encodeForDataMap(row);
260264
}

api/src/org/labkey/api/data/ContainerManager.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,13 +1951,6 @@ private static boolean delete(final Container c, User user, @Nullable String com
19511951
// and delete all container-based sequences
19521952
DbSequenceManager.deleteAll(c);
19531953

1954-
ExperimentService experimentService = ExperimentService.get();
1955-
if (experimentService != null)
1956-
{
1957-
experimentService.removeContainerDataTypeExclusions(c.getId());
1958-
experimentService.removeContainerDataColorExclusions(c.getId());
1959-
}
1960-
19611954
// Issue 17015: After we've committed the transaction, be sure that we remove this container from the cache
19621955
tx.addCommitTask(() ->
19631956
{

api/src/org/labkey/api/exp/api/ExperimentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ List<? extends ExpProtocol> getExpProtocolsWithParameterValue(
11601160

11611161
void removeDataColorExclusionsForDataType(long dataTypeId, DataTypeForExclusion dataType);
11621162

1163-
void removeContainerDataColorExclusions(String containerId);
1163+
void removeContainerDataColors(String containerId);
11641164

11651165
void registerRunInputsViewProvider(QueryViewProvider<ExpRun> provider);
11661166

experiment/src/org/labkey/experiment/api/DataColorTable.java

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -466,34 +466,10 @@ public void testArchivedNonExcludedColorCanBeImported() throws Exception
466466
assertNull("an archived non-excluded color should still be insertable", saveSample(st, sampleRow("s1", gray), false));
467467
}
468468

469-
@Test
470-
public void testCannotInsertSampleWithBadColor() throws Exception
471-
{
472-
473-
ExpSampleType st = createSampleType("ColorCaseST");
474-
insertColor("Red", "#ff0000", false);
475-
476-
Map<String, Object> exactCase = new CaseInsensitiveHashMap<>();
477-
exactCase.put("Name", "exactCase");
478-
exactCase.put("ExpMaterialColor", "Red");
479-
assertNull("a sample referencing the color by its exact label should import", saveSample(st, exactCase, false));
480-
481-
// cannot insert sample with colr differing by case
482-
Map<String, Object> wrongCase = new CaseInsensitiveHashMap<>();
483-
wrongCase.put("Name", "wrongCase");
484-
wrongCase.put("ExpMaterialColor", "red");
485-
String err = saveSample(st, wrongCase, false);
486-
assertNotNull("a color label differing only by case should not resolve to the existing color", err);
487-
assertTrue("Unexpected error: " + err, err.toLowerCase().contains("not found"));
488-
489-
// cannot insert sample with non-existent color
490-
Map<String, Object> unknown = new CaseInsensitiveHashMap<>();
491-
unknown.put("Name", "unknownColor");
492-
unknown.put("ExpMaterialColor", "Purple"); // no such color exists
493-
err = saveSample(st, unknown, false);
494-
assertNotNull("a sample referencing a nonexistent color should be rejected", err);
495-
assertTrue("Unexpected error: " + err, err.toLowerCase().contains("not found"));
496-
}
469+
// Note: resolving a color by its Label (and rejecting a wrong-case or nonexistent label) is an import-path
470+
// concern — the label -> rowId remap happens in the ETL/import DataIterator, not in a direct QUS insertRows
471+
// (which expects the ExpMaterialColor key). That coverage lives in the remoteapi SMSampleColorsApiTest, which
472+
// imports by label via QueryApiHelper.importData.
497473

498474
// ---- exclusion service methods --------------------------------------
499475

experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5622,6 +5622,9 @@ public void deleteAllExpObjInContainer(Container c, User user) throws Experiment
56225622
LOG.debug("Deleting objects from container {}", c);
56235623
OntologyManager.deleteAllObjects(c, user);
56245624

5625+
removeContainerDataTypeExclusions(c.getId());
5626+
removeContainerDataColors(c.getId());
5627+
56255628
transaction.commit();
56265629
}
56275630
catch (ValidationException e)
@@ -9260,7 +9263,7 @@ public void removeDataColorExclusionsForDataType(long dataTypeId, DataTypeForExc
92609263
}
92619264

92629265
@Override
9263-
public void removeContainerDataColorExclusions(String containerId)
9266+
public void removeContainerDataColors(String containerId)
92649267
{
92659268
SqlExecutor executor = new SqlExecutor(getExpSchema());
92669269
SQLFragment delExclusions = new SQLFragment("DELETE FROM ")

0 commit comments

Comments
 (0)