From 5c42ecdc10a1ad865708065aab27ef55f13d7e9d Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Tue, 4 May 2021 16:44:01 -0700 Subject: [PATCH 1/2] A recently added trigger script is now validating there is an "enddate" value, but the test has always been using the incorrectly named "end" field --- .../test/tests/onprc_ehr/ONPRC_EHRTest.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java b/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java index d67915e50..148cb7d6d 100644 --- a/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java +++ b/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java @@ -74,6 +74,7 @@ import java.util.Set; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; @Category({CustomModules.class, EHR.class, ONPRC.class}) @BaseWebDriverTest.ClassTimeout(minutes = 60) @@ -195,15 +196,28 @@ public void testAssignmentApi() throws Exception projectSelect.addFilter(new Filter("protocol", protocolId)); final Integer projectId = (Integer)projectSelect.execute(getApiHelper().getConnection(), getContainerPath()).getRows().get(0).get("project"); + // Try with a row that doesn't pass validation + Map protocolCountsRow = new HashMap<>(); + protocolCountsRow.put("protocol", protocolId); + protocolCountsRow.put("species", "Cynomolgus"); + protocolCountsRow.put("allowed", 2); + protocolCountsRow.put("start", prepareDate(new Date(), -10, 0)); + try + { + InsertRowsCommand protocolCountsCommand = new InsertRowsCommand("ehr", "protocol_counts"); + protocolCountsCommand.addRow(protocolCountsRow); + protocolCountsCommand.execute(getApiHelper().getConnection(), getContainerPath()); + fail("Should have gotten an exception due to missing end date"); + } + catch (CommandException e) + { + assertEquals("Wrong failure message", "ERROR: Must enter Start and End dates", e.getMessage()); + } + + // Then try again with the problem corrected + protocolCountsRow.put("end", prepareDate(new Date(), 370, 0)); InsertRowsCommand protocolCountsCommand = new InsertRowsCommand("ehr", "protocol_counts"); - protocolCountsCommand.addRow(new HashMap(){ - { - put("protocol", protocolId); - put("species", "Cynomolgus"); - put("allowed", 2); - put("start", prepareDate(new Date(), -10, 0)); - put("end", prepareDate(new Date(), 370, 0)); - }}); + protocolCountsCommand.addRow(protocolCountsRow); protocolCountsCommand.execute(getApiHelper().getConnection(), getContainerPath()); //create assignment From 35eb8a8e56e8ade9fb42403cde2e74790948c229 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Tue, 4 May 2021 16:58:30 -0700 Subject: [PATCH 2/2] Use corrected column name --- ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java b/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java index 148cb7d6d..8a63e76f0 100644 --- a/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java +++ b/ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java @@ -215,7 +215,7 @@ public void testAssignmentApi() throws Exception } // Then try again with the problem corrected - protocolCountsRow.put("end", prepareDate(new Date(), 370, 0)); + protocolCountsRow.put("enddate", prepareDate(new Date(), 370, 0)); InsertRowsCommand protocolCountsCommand = new InsertRowsCommand("ehr", "protocol_counts"); protocolCountsCommand.addRow(protocolCountsRow); protocolCountsCommand.execute(getApiHelper().getConnection(), getContainerPath());