RegisterController { @RequestMapping(method = GET, value = "/registers/pnc") @ResponseBody public ResponseEntity<PNCRegisterDTO> pncRegister(@RequestParam("anm-id") String anmIdentifier) { PNCRegister pncRegister = pncRegisterService.getRegisterForANM(anmIdentifier); return new ResponseEntity<>(pncRegisterMapper.mapToDTO(pncRegister), HttpStatus.OK); } @Autowired  RegisterController(ANCRegisterService ancRegisterService,
                              PNCRegisterService pncRegisterService,
                              ECRegisterService ecRegisterService,
                              ChildRegisterService childRegisterService,
                              FPRegisterService fpRegisterService,
                              ANCRegisterMapper ancRegisterMapper,
                              ECRegisterMapper ecRegisterMapper,
                              ChildRegisterMapper childRegisterMapper,
                              FPRegisterMapper fpRegisterMapper,
                              PNCRegisterMapper pncRegisterMapper); @RequestMapping(method = GET, value = "/registers/ec") @ResponseBody ResponseEntity<ECRegisterDTO> ecRegister(@RequestParam("anm-id") String anmIdentifier); @RequestMapping(method = GET, value = "/registers/anc") @ResponseBody ResponseEntity<ANCRegisterDTO> ancRegister(@RequestParam("anm-id") String anmIdentifier); @RequestMapping(method = GET, value = "/registers/child") @ResponseBody ResponseEntity<ChildRegisterDTO> childRegister(@RequestParam("anm-id") String anmIdentifier); @RequestMapping(method = GET, value = "/registers/fp") @ResponseBody ResponseEntity<FPRegisterDTO> fpRegister(@RequestParam("anm-id") String anmIdentifier); @RequestMapping(method = GET, value = "/registers/pnc") @ResponseBody ResponseEntity<PNCRegisterDTO> pncRegister(@RequestParam("anm-id") String anmIdentifier);  }
@Test public void shouldGetPNCRegisterForGivenANM() throws Exception { PNCRegister pncRegister = new PNCRegister(asList(new PNCRegisterEntry() .withRegistrationDate("2014-01-01") .withThayiCardNumber("thayi card number 1") .withWifeName("name1") .withHusbandName("name2") .withWifeDOB("1989-01-01") .withAddress("address1") .withDateOfDelivery("2014-01-01") .withPlaceOfDelivery("phc") .withTypeOfDelivery("normal") .withDischargeDate("2014-01-01") .withFPMethodName("female_sterilization") .withFPMethodDate("2014-01-01") .withDeliveryComplications("difficulty breathing") .withChildrenDetails(asList(create("id", "123") .put("sex", "male") .put("birthWeight", "2") .put("breastFeedingInOneHour", "yes") .map(), create("id", "234") .put("sex", "male") .put("birthWeight", "2") .put("breastFeedingInOneHour", "yes") .map() ) ).withPNCVisits(asList(new PNCVisit() .withDate("2014-01-01") .withPerson("ASHA") .withPlace("phc") .withDifficulties("difficulty 1") .withAbdominalProblems("abdominal problem") .withVaginalProblems("vaginal problem") .withUrinalProblems("urinal problem") .withBreastProblems("breast problem") .withChildrenDetails(asList(create("id", "123") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map(), create("id", "234") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map() ) ), new PNCVisit() .withDate("2014-01-02") .withPerson("ASHA") .withPlace("phc") .withDifficulties("difficulty 1") .withAbdominalProblems("abdominal problem") .withVaginalProblems("vaginal problem") .withUrinalProblems("urinal problem") .withBreastProblems("breast problem") .withChildrenDetails(asList(create("id", "123") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map(), create("id", "234") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map() ) ) )))); PNCRegisterDTO expectedPNCRegisterDTO = new PNCRegisterDTO(asList(new PNCRegisterEntryDTO().withRegistrationDate("2014-01-01") .withThayiCardNumber("thayi card number 1") .withWifeName("name1") .withHusbandName("name2") .withWifeDOB("1989-01-01") .withAddress("address1") .withDateOfDelivery("2014-01-01") .withPlaceOfDelivery("phc") .withTypeOfDelivery("normal") .withDischargeDate("2014-01-01") .withFPMethodName("female_sterilization") .withFPMethodDate("2014-01-01") .withDeliveryComplications("difficulty breathing") .withChildrenDetails(asList(create("id", "123") .put("sex", "male") .put("birthWeight", "2") .put("breastFeedingInOneHour", "yes") .map(), create("id", "234") .put("sex", "male") .put("birthWeight", "2") .put("breastFeedingInOneHour", "yes") .map() ) ).withPNCVisits(asList(new PNCVisitDTO() .withDate("2014-01-01") .withPerson("ASHA") .withPlace("phc") .withDifficulties("difficulty 1") .withAbdominalProblems("abdominal problem") .withVaginalProblems("vaginal problem") .withUrinalProblems("urinal problem") .withBreastProblems("breast problem") .withChildrenDetails(asList(create("id", "123") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map(), create("id", "234") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map() ) ), new PNCVisitDTO() .withDate("2014-01-02") .withPerson("ASHA") .withPlace("phc") .withDifficulties("difficulty 1") .withAbdominalProblems("abdominal problem") .withVaginalProblems("vaginal problem") .withUrinalProblems("urinal problem") .withBreastProblems("breast problem") .withChildrenDetails(asList(create("id", "123") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map(), create("id", "234") .put("complications 1", "complication 1 value") .put("complications 2", "complications 2 value") .map() ) ))) )); when(pncRegisterService.getRegisterForANM("anm1")).thenReturn(pncRegister); when(pncRegisterMapper.mapToDTO(pncRegister)).thenReturn(expectedPNCRegisterDTO); ResponseEntity<PNCRegisterDTO> response = controller.pncRegister("anm1"); assertEquals(expectedPNCRegisterDTO, response.getBody()); assertEquals(HttpStatus.OK, response.getStatusCode()); }