RegisterController { @RequestMapping(method = GET, value = "/registers/anc") @ResponseBody public ResponseEntity<ANCRegisterDTO> ancRegister(@RequestParam("anm-id") String anmIdentifier) { ANCRegister ancRegister = ancRegisterService.getRegisterForANM(anmIdentifier); return new ResponseEntity<>(ancRegisterMapper.mapToDTO(ancRegister), 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 shouldGetANCRegisterForGivenANM() throws Exception { ANCRegister ancRegister = new ANCRegister(asList(new ANCRegisterEntry() .withANCNumber("OA899") .withRegistrationDate("2014-01-01") .withECNumber("123") .withThayiCardNumber("thayi card number 1") .withAadharCardNumber("aadhar card number 1") .withWifeName("name1") .withHusbandName("name2") .withAddress("address1") .withWifeDOB("1989-01-01") .withPhoneNumber("phone 1") .withWifeEducationLevel("wife education level") .withHusbandEducationLevel("husband education level") .withCaste("sc") .withReligion("hindu") .withEconomicStatus("bpl") .withBPLCardNumber("bpl card number 1") .withJSYBeneficiary("yes") .withGravida("1") .withParity("2") .withNumberOfLivingChildren("3") .withNumberOfStillBirths("4") .withNumberOfAbortions("5") .withYoungestChildDOB("2012-01-01") .withLMP("2013-12-30") .withEDD("2014-09-01") .withHeight("150") .withBloodGroup("o -ve") .withIsHRP("yes"))); ANCRegisterDTO expectedANCRegisterDTO = new ANCRegisterDTO(asList(new ANCRegisterEntryDTO() .withANCNumber("OA899") .withRegistrationDate("2014-01-01") .withECNumber("123") .withThayiCardNumber("thayi card number 1") .withAadharCardNumber("aadhar card number 1") .withWifeName("name1") .withHusbandName("name2") .withAddress("address1") .withWifeDOB("1989-01-01") .withPhoneNumber("phone 1") .withWifeEducationLevel("wife education level") .withHusbandEducationLevel("husband education level") .withCaste("sc") .withReligion("hindu") .withEconomicStatus("bpl") .withBPLCardNumber("bpl card number 1") .withJSYBeneficiary("yes") .withGravida("1") .withParity("2") .withNumberOfLivingChildren("3") .withNumberOfStillBirths("4") .withNumberOfAbortions("5") .withYoungestChildDOB("2012-01-01") .withLMP("2013-12-30") .withEDD("2014-09-01") .withHeight("150") .withBloodGroup("o -ve") .withIsHRP("yes"))); when(ancRegisterService.getRegisterForANM("anm1")).thenReturn(ancRegister); when(ancRegisterMapper.mapToDTO(ancRegister)).thenReturn(expectedANCRegisterDTO); ResponseEntity<ANCRegisterDTO> response = controller.ancRegister("anm1"); assertEquals(expectedANCRegisterDTO, response.getBody()); assertEquals(HttpStatus.OK, response.getStatusCode()); }