diff --git a/flw/src/main/java/org/motechproject/nms/flw/exception/FlwExistingRecordException.java b/flw/src/main/java/org/motechproject/nms/flw/exception/FlwExistingRecordException.java new file mode 100644 index 000000000..74c7a1e8e --- /dev/null +++ b/flw/src/main/java/org/motechproject/nms/flw/exception/FlwExistingRecordException.java @@ -0,0 +1,11 @@ +package org.motechproject.nms.flw.exception; + +/** + * Signals an issue with importing an FLW which already exits in database. + */ +public class FlwExistingRecordException extends Exception { + + public FlwExistingRecordException(String message) { + super(message); + } +} diff --git a/flw/src/main/java/org/motechproject/nms/flw/service/FrontLineWorkerImportService.java b/flw/src/main/java/org/motechproject/nms/flw/service/FrontLineWorkerImportService.java index c5918a61c..d69ba8868 100644 --- a/flw/src/main/java/org/motechproject/nms/flw/service/FrontLineWorkerImportService.java +++ b/flw/src/main/java/org/motechproject/nms/flw/service/FrontLineWorkerImportService.java @@ -1,5 +1,6 @@ package org.motechproject.nms.flw.service; +import org.motechproject.nms.flw.exception.FlwExistingRecordException; import org.motechproject.nms.region.domain.State; import org.motechproject.nms.region.exception.InvalidLocationException; @@ -11,5 +12,5 @@ public interface FrontLineWorkerImportService { void importData(Reader reader) throws IOException; - void importFrontLineWorker(Map record, State state) throws InvalidLocationException; + void importFrontLineWorker(Map record, State state) throws InvalidLocationException, FlwExistingRecordException; } diff --git a/flw/src/main/java/org/motechproject/nms/flw/service/impl/FrontLineWorkerImportServiceImpl.java b/flw/src/main/java/org/motechproject/nms/flw/service/impl/FrontLineWorkerImportServiceImpl.java index 01fbbb77b..892f12591 100644 --- a/flw/src/main/java/org/motechproject/nms/flw/service/impl/FrontLineWorkerImportServiceImpl.java +++ b/flw/src/main/java/org/motechproject/nms/flw/service/impl/FrontLineWorkerImportServiceImpl.java @@ -10,6 +10,7 @@ import org.motechproject.nms.csv.utils.GetString; import org.motechproject.nms.flw.domain.FrontLineWorker; +import org.motechproject.nms.flw.exception.FlwExistingRecordException; import org.motechproject.nms.flw.exception.FlwImportException; import org.motechproject.nms.flw.service.FrontLineWorkerImportService; import org.motechproject.nms.flw.service.FrontLineWorkerService; @@ -72,14 +73,14 @@ public void importData(Reader reader) throws IOException { } } catch (ConstraintViolationException e) { throw new CsvImportDataException(createErrorMessage(e.getConstraintViolations(), csvImporter.getRowNumber()), e); - } catch (InvalidLocationException | FlwImportException | JDODataStoreException e) { + } catch (InvalidLocationException | FlwImportException | JDODataStoreException | FlwExistingRecordException e) { throw new CsvImportDataException(createErrorMessage(e.getMessage(), csvImporter.getRowNumber()), e); } } @Override @Transactional - public void importFrontLineWorker(Map record, State state) throws InvalidLocationException { + public void importFrontLineWorker(Map record, State state) throws InvalidLocationException, FlwExistingRecordException { FrontLineWorker flw = flwFromRecord(record, state); record.put(FlwConstants.STATE_ID, state.getCode()); @@ -92,6 +93,8 @@ public void importFrontLineWorker(Map record, State state) throw //It updated_date_nic from mcts is not null,then it's not a new record. Compare it with the record from database and update if (mctsUpdatedDateNic != null && (flw.getUpdatedDateNic() == null || mctsUpdatedDateNic.isAfter(flw.getUpdatedDateNic()) || mctsUpdatedDateNic.isEqual(flw.getUpdatedDateNic()))) { frontLineWorkerService.update(updateFlw(flw, record, location)); + } else { + throw new FlwExistingRecordException("Updated record exists in the database"); } } } diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java index 6a4c697d9..61626c4cb 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java @@ -187,7 +187,7 @@ public boolean importMotherRecord(Map record) { //validate if it's an updated record compared to one from database if (mother.getUpdatedDateNic() != null && (mctsUpdatedDateNic == null || mother.getUpdatedDateNic().isAfter(mctsUpdatedDateNic))) { - return true; + return false; } mother.setName(name); @@ -254,7 +254,7 @@ public boolean importChildRecord(Map record) { //validate if it's an updated record compared to one from database if (child.getUpdatedDateNic() != null && (mctsUpdatedDateNic == null || child.getUpdatedDateNic().isAfter(mctsUpdatedDateNic))) { - return true; + return false; } child.setName(name); diff --git a/mcts/src/main/java/org/motechproject/nms/mcts/handler/MctsImportJobHandler.java b/mcts/src/main/java/org/motechproject/nms/mcts/handler/MctsImportJobHandler.java index e6b69b212..930ae68f4 100644 --- a/mcts/src/main/java/org/motechproject/nms/mcts/handler/MctsImportJobHandler.java +++ b/mcts/src/main/java/org/motechproject/nms/mcts/handler/MctsImportJobHandler.java @@ -57,6 +57,7 @@ public void initImportJob() { throw new MctsImportConfigurationException("Cron expression from setting is invalid: " + cronExpression); } + LOGGER.info("Created MCTS Import Event"); CronSchedulableJob mctsImportJob = new CronSchedulableJob(new MotechEvent(Constants.MCTS_IMPORT_EVENT), cronExpression); motechSchedulerService.safeScheduleJob(mctsImportJob); } diff --git a/mcts/src/main/java/org/motechproject/nms/mcts/service/impl/MctsWsImportServiceImpl.java b/mcts/src/main/java/org/motechproject/nms/mcts/service/impl/MctsWsImportServiceImpl.java index d9cc59e27..21d1fee04 100644 --- a/mcts/src/main/java/org/motechproject/nms/mcts/service/impl/MctsWsImportServiceImpl.java +++ b/mcts/src/main/java/org/motechproject/nms/mcts/service/impl/MctsWsImportServiceImpl.java @@ -12,6 +12,7 @@ import org.motechproject.event.listener.annotations.MotechListener; import org.motechproject.mds.query.QueryParams; import org.motechproject.mds.util.Order; +import org.motechproject.nms.flw.exception.FlwExistingRecordException; import org.motechproject.nms.flw.exception.FlwImportException; import org.motechproject.nms.flw.service.FrontLineWorkerImportService; import org.motechproject.nms.kilkari.service.MctsBeneficiaryImportService; @@ -402,6 +403,9 @@ private MctsImportAudit saveImportedAnmAshaData(AnmAshaDataSet anmAshaDataSet, S } catch (FlwImportException e) { LOGGER.error("Existing FLW with same MSISDN but different MCTS ID", e); rejected++; + } catch (FlwExistingRecordException e) { + LOGGER.error("Cannot import FLW with ID: {}, and MSISDN (Contact_No): {}", record.getId(), record.getContactNo(), e); + rejected++; } catch (Exception e) { LOGGER.error("Flw import Error. Cannot import FLW with ID: {}, and MSISDN (Contact_No): {}", record.getId(), record.getContactNo(), e); diff --git a/mcts/src/main/resources/MctsAuditModification.sql b/mcts/src/main/resources/MctsAuditModification.sql deleted file mode 100644 index f004c658c..000000000 --- a/mcts/src/main/resources/MctsAuditModification.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE motech_data_services.nms_mcts_audit CHANGE importDate endImportDate DATE NULL; \ No newline at end of file diff --git a/testing/src/test/java/org/motechproject/nms/testing/it/imi/CdrFileServiceBundleIT.java b/testing/src/test/java/org/motechproject/nms/testing/it/imi/CdrFileServiceBundleIT.java index 7d88e9e3f..b623a6c31 100644 --- a/testing/src/test/java/org/motechproject/nms/testing/it/imi/CdrFileServiceBundleIT.java +++ b/testing/src/test/java/org/motechproject/nms/testing/it/imi/CdrFileServiceBundleIT.java @@ -56,7 +56,7 @@ public class CdrFileServiceBundleIT extends BasePaxIT { private static final String PROCESS_FILES_SUBJECT = "nms.imi.kk.process_files"; - private static final long MAX_MILLISECOND_WAIT = 10000L; + private static final long MAX_MILLISECOND_WAIT = 2000L; private static final String INITIAL_RETRY_DELAY = "imi.initial_retry_delay"; private static final String MAX_CDR_ERROR_COUNT = "imi.max_cdr_error_count"; diff --git a/testing/src/test/java/org/motechproject/nms/testing/it/mcts/MctsImportBundleIT.java b/testing/src/test/java/org/motechproject/nms/testing/it/mcts/MctsImportBundleIT.java index 59827ea56..eb6924505 100644 --- a/testing/src/test/java/org/motechproject/nms/testing/it/mcts/MctsImportBundleIT.java +++ b/testing/src/test/java/org/motechproject/nms/testing/it/mcts/MctsImportBundleIT.java @@ -9,6 +9,7 @@ import org.motechproject.commons.date.util.DateUtil; import org.motechproject.event.MotechEvent; import org.motechproject.nms.flw.domain.FrontLineWorker; +import org.motechproject.nms.flw.exception.FlwExistingRecordException; import org.motechproject.nms.flw.repository.FrontLineWorkerDataService; import org.motechproject.nms.imi.service.SettingsService; import org.motechproject.nms.kilkari.domain.MctsChild; @@ -158,18 +159,16 @@ public void setUp() throws ServletException, NamespaceException { districtDataService.create(district); - SubscriptionPack pregnancyPack = new SubscriptionPack("prg", SubscriptionPackType.PREGNANCY, 10, 10, + SubscriptionPack pregnancyPack = new SubscriptionPack("prg", SubscriptionPackType.PREGNANCY, 70, 10, Collections.emptyList()); - SubscriptionPack childPack = new SubscriptionPack("child", SubscriptionPackType.CHILD, 5000, 6, + SubscriptionPack childPack = new SubscriptionPack("child", SubscriptionPackType.CHILD, 5000, 6, Collections.emptyList()); - subscriptionPackDataService.create(pregnancyPack); subscriptionPackDataService.create(childPack); - httpService.registerServlet("/mctsWs", new MockWsHttpServlet(), null, null); httpService.registerServlet("/mctsWsFailedStructure", new MockWsHttpServletForFail(), null, null); httpService.registerServlet("/mctsWsRemoteException", new MockWsHttpServletRemoteException(), null, null); @@ -195,14 +194,15 @@ public void shouldUpdateFailedTableWhenImportFailsDueToFailedStructure() throws LocalDate yesterday = DateUtil.today().minusDays(1); List stateIds = singletonList(21L); - + // this CL workaround is for an issue with PAX IT logging messing things up + // shouldn't affect production ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(mctsWsImportService.getClass().getClassLoader()); // setup motech event Map params = new HashMap<>(); params.put(Constants.START_DATE_PARAM, lastDateToCheck); - params.put(Constants.END_DATE_PARAM,yesterday); + params.put(Constants.END_DATE_PARAM, yesterday); params.put(Constants.STATE_ID_PARAM, 21L); params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params); @@ -212,13 +212,8 @@ public void shouldUpdateFailedTableWhenImportFailsDueToFailedStructure() throws Thread.currentThread().setContextClassLoader(cl); // Since the structure is wrong in the xmls, the import should not take place and the data should be updated in nms_mcts_failure table - List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); - assertEquals(3,mctsImportFailRecords.size()); - - - - + assertEquals(3, mctsImportFailRecords.size()); } @@ -229,14 +224,15 @@ public void shouldUpdateFailedTableWhenImportFailsDueRemoteException() throws Ma LocalDate yesterday = DateUtil.today().minusDays(1); List stateIds = singletonList(21L); - + // this CL workaround is for an issue with PAX IT logging messing things up + // shouldn't affect production ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(mctsWsImportService.getClass().getClassLoader()); // setup motech event Map params = new HashMap<>(); params.put(Constants.START_DATE_PARAM, lastDateToCheck); - params.put(Constants.END_DATE_PARAM,yesterday); + params.put(Constants.END_DATE_PARAM, yesterday); params.put(Constants.STATE_ID_PARAM, 21L); params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params); @@ -246,16 +242,13 @@ public void shouldUpdateFailedTableWhenImportFailsDueRemoteException() throws Ma Thread.currentThread().setContextClassLoader(cl); // Since the response while reading the xmls is a Remote server exception, the import should not take place and the data should be updated in nms_mcts_failure table - List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); - assertEquals(3,mctsImportFailRecords.size()); - - - + assertEquals(3, mctsImportFailRecords.size()); } + @Test public void shouldPerformImportWithUpdatesAndDeleteInFailedTable() throws MalformedURLException { URL endpoint = new URL(String.format("http://localhost:%d/mctsWs", TestContext.getJettyPort())); @@ -263,11 +256,11 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTable() throws Malfor LocalDate lastDateToCheck = DateUtil.today().minusDays(7); LocalDate failDate = DateUtil.today().minusDays(2); LocalDate yesterday = DateUtil.today().minusDays(1); - MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate,MctsUserType.ASHA,21L); + MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate, MctsUserType.ASHA, 21L); - MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate,MctsUserType.MOTHER,21L); + MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate, MctsUserType.MOTHER, 21L); - MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate,MctsUserType.CHILD,21L); + MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate, MctsUserType.CHILD, 21L); mctsImportFailRecordDataService.create(mctsImportFailRecord1); mctsImportFailRecordDataService.create(mctsImportFailRecord2); @@ -275,7 +268,8 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTable() throws Malfor try { TimeFaker.fakeToday(DateUtil.newDate(2015, 7, 24)); - + // this CL workaround is for an issue with PAX IT logging messing things up + // shouldn't affect production ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(mctsWsImportService.getClass().getClassLoader()); @@ -287,18 +281,23 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTable() throws Malfor params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params); - - - /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ + /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ mctsWsImportService.importMothersData(event); mctsWsImportService.importChildrenData(event); mctsWsImportService.importAnmAshaData(event); Thread.currentThread().setContextClassLoader(cl); - // we expect two of each - the second entry in each ds (4 total) has wrong location data and the first one is a duplicate of the fourth record with updated date. So the updated record should stay. The audit table should update with three errors created manually above. And after the import the three errors should clear from failure table. - List mctsImportAudits= mctsImportAuditDataService.retrieveAll(); - assertEquals(3,mctsImportAudits.size()); + List mctsImportAudits = mctsImportAuditDataService.retrieveAll(); + assertEquals(3, mctsImportAudits.size()); + assertEquals(2, mctsImportAudits.get(0).getAccepted()); + assertEquals(2, mctsImportAudits.get(0).getRejected()); + assertEquals(2, mctsImportAudits.get(1).getAccepted()); + assertEquals(2, mctsImportAudits.get(1).getRejected()); + assertEquals(2, mctsImportAudits.get(2).getAccepted()); + assertEquals(2, mctsImportAudits.get(2).getRejected()); + assertEquals(lastDateToCheck, mctsImportAudits.get(0).getStartImportDate()); + assertEquals(yesterday, mctsImportAudits.get(0).getEndImportDate()); List flws = flwDataService.retrieveAll(); assertEquals(2, flws.size()); @@ -314,7 +313,7 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTable() throws Malfor List mothers = mctsMotherDataService.retrieveAll(); assertEquals(2, mothers.size()); assertEquals("Name x", mothers.get(0).getName()); - }finally { + } finally { TimeFaker.stopFakingTime(); } @@ -328,11 +327,11 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableNoUpdateDate() t LocalDate lastDateToCheck = DateUtil.today().minusDays(7); LocalDate failDate = DateUtil.today().minusDays(2); LocalDate yesterday = DateUtil.today().minusDays(1); - MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate,MctsUserType.ASHA,21L); + MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate, MctsUserType.ASHA, 21L); - MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate,MctsUserType.MOTHER,21L); + MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate, MctsUserType.MOTHER, 21L); - MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate,MctsUserType.CHILD,21L); + MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate, MctsUserType.CHILD, 21L); mctsImportFailRecordDataService.create(mctsImportFailRecord1); mctsImportFailRecordDataService.create(mctsImportFailRecord2); @@ -340,7 +339,8 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableNoUpdateDate() t try { TimeFaker.fakeToday(DateUtil.newDate(2015, 7, 24)); - + // this CL workaround is for an issue with PAX IT logging messing things up + // shouldn't affect production ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(mctsWsImportService.getClass().getClassLoader()); @@ -352,9 +352,7 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableNoUpdateDate() t params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params); - - - /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ + /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ mctsWsImportService.importMothersData(event); mctsWsImportService.importChildrenData(event); mctsWsImportService.importAnmAshaData(event); @@ -362,27 +360,24 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableNoUpdateDate() t // we expect two of each - the second entry in each ds (4 total) has wrong location data and the first one is a duplicate of the fourth record with no updated dates on any record. So only one of the duplicates should be in the database. And after the import the three errors should clear from failure table. + List flws = flwDataService.retrieveAll(); + assertEquals(2, flws.size()); + List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); + assertEquals(0, mctsImportFailRecords.size()); + assertEquals("Sample Name 1", flws.get(0).getName()); - List flws = flwDataService.retrieveAll(); - assertEquals(2, flws.size()); - - List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); - assertEquals(0,mctsImportFailRecords.size()); - assertEquals("Sample Name 1",flws.get(0).getName()); - - List children = mctsChildDataService.retrieveAll(); - assertEquals(2, children.size()); - assertEquals("Name 1",children.get(0).getName()); + List children = mctsChildDataService.retrieveAll(); + assertEquals(2, children.size()); + assertEquals("Name 1", children.get(0).getName()); - List mothers = mctsMotherDataService.retrieveAll(); - assertEquals(2, mothers.size()); - assertEquals("Name 1",mothers.get(0).getName()); + List mothers = mctsMotherDataService.retrieveAll(); + assertEquals(2, mothers.size()); + assertEquals("Name 1", mothers.get(0).getName()); - }finally { + } finally { TimeFaker.stopFakingTime(); } - } @Test @@ -392,11 +387,11 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableOneUpdateDate() LocalDate lastDateToCheck = DateUtil.today().minusDays(7); LocalDate failDate = DateUtil.today().minusDays(2); LocalDate yesterday = DateUtil.today().minusDays(1); - MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate,MctsUserType.ASHA,21L); + MctsImportFailRecord mctsImportFailRecord1 = new MctsImportFailRecord(failDate, MctsUserType.ASHA, 21L); - MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate,MctsUserType.MOTHER,21L); + MctsImportFailRecord mctsImportFailRecord2 = new MctsImportFailRecord(failDate, MctsUserType.MOTHER, 21L); - MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate,MctsUserType.CHILD,21L); + MctsImportFailRecord mctsImportFailRecord3 = new MctsImportFailRecord(failDate, MctsUserType.CHILD, 21L); mctsImportFailRecordDataService.create(mctsImportFailRecord1); mctsImportFailRecordDataService.create(mctsImportFailRecord2); @@ -405,6 +400,8 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableOneUpdateDate() try { TimeFaker.fakeToday(DateUtil.newDate(2015, 7, 24)); + // this CL workaround is for an issue with PAX IT logging messing things up + // shouldn't affect production ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(mctsWsImportService.getClass().getClassLoader()); @@ -416,34 +413,29 @@ public void shouldPerformImportWithUpdatesAndDeleteInFailedTableOneUpdateDate() params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params); - - - /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ + /* Hard to test this since we do async loading now, using test hook. UT already tests message distribution */ mctsWsImportService.importMothersData(event); mctsWsImportService.importChildrenData(event); mctsWsImportService.importAnmAshaData(event); Thread.currentThread().setContextClassLoader(cl); - // we expect one of each - the first entry in each ds (2 total) has an updated dated unlike the previous data. So only the one with updated date should be in the database. And after the import the three errors should clear from failure table. + List flws = flwDataService.retrieveAll(); + assertEquals(1, flws.size()); + List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); + assertEquals(0, mctsImportFailRecords.size()); + assertEquals("Name a", flws.get(0).getName()); - List flws = flwDataService.retrieveAll(); - assertEquals(1, flws.size()); - - List mctsImportFailRecords = mctsImportFailRecordDataService.retrieveAll(); - assertEquals(0,mctsImportFailRecords.size()); - assertEquals("Name a",flws.get(0).getName()); - - List children = mctsChildDataService.retrieveAll(); - assertEquals(1, children.size()); - assertEquals("Name y",children.get(0).getName()); + List children = mctsChildDataService.retrieveAll(); + assertEquals(1, children.size()); + assertEquals("Name y", children.get(0).getName()); - List mothers = mctsMotherDataService.retrieveAll(); - assertEquals(1, mothers.size()); - assertEquals("Name x",mothers.get(0).getName()); + List mothers = mctsMotherDataService.retrieveAll(); + assertEquals(1, mothers.size()); + assertEquals("Name x", mothers.get(0).getName()); - }finally { + } finally { TimeFaker.stopFakingTime(); } @@ -472,7 +464,7 @@ public void shouldFilterHpdImport() throws MalformedURLException { // setup motech event Map params = new HashMap<>(); params.put(Constants.START_DATE_PARAM, lastDayToCheck); - params.put(Constants.END_DATE_PARAM,yesterday); + params.put(Constants.END_DATE_PARAM, yesterday); params.put(Constants.STATE_ID_PARAM, 21L); params.put(Constants.ENDPOINT_PARAM, endpoint); MotechEvent event = new MotechEvent("foobar", params);