ANCService { public void hbTest(FormSubmission submission) { Mother mother = allMothers.findByCaseId(submission.entityId()); if (mother == null) { logger.warn("Tried to handle Hb test given without registered mother. Submission: " + submission); return; } Map<String, String> hbTest = create(HB_TEST_DATE_FIELD, submission.getField(HB_TEST_DATE_FIELD)) .put(HB_LEVEL_FIELD, submission.getField(HB_LEVEL_FIELD)) .map(); mother.updateHBTestInformation(hbTest); allMothers.update(mother); ancSchedulesService.hbTestDone(submission.entityId(), submission.anmId(), submission.getField(HB_TEST_DATE_FIELD), submission.getField(ANAEMIC_STATUS_FIELD), mother.lmp()); } @Autowired  ANCService(AllMothers allMothers,
                      AllEligibleCouples eligibleCouples,
                      ANCSchedulesService ancSchedulesService,
                      ActionService actionService,
                      MotherReportingService reportingService,
                      ReportFieldsDefinition reportFieldsDefinition); void registerANC(FormSubmission submission); void registerOutOfAreaANC(FormSubmission submission); void ancVisit(FormSubmission submission); void ttProvided(FormSubmission submission); void ifaTabletsGiven(FormSubmission submission); void hbTest(FormSubmission submission); void deliveryPlanned(FormSubmission submission); void deliveryOutcome(FormSubmission submission); void close(FormSubmission submission); void ancInvestigations(FormSubmission submission);  }
@Test public void shouldHandleHbTest() { FormSubmission submission = create() .withFormName("tt_1") .withANMId("anm id 1") .withEntityId("entity id 1") .addFormField("hbTestDate", "2013-01-01") .addFormField("anaemicStatus", "Anaemic") .build(); when(allMothers.findByCaseId("entity id 1")).thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1").withLMP(parse("2012-01-01"))); service.hbTest(submission); verify(ancSchedulesService).hbTestDone("entity id 1", "anm id 1", "2013-01-01", "Anaemic", parse("2012-01-01")); }