RegisterController { @RequestMapping(method = GET, value = "/registers/ec") @ResponseBody public ResponseEntity<ECRegisterDTO> ecRegister(@RequestParam("anm-id") String anmIdentifier) { ECRegister ecRegister = ecRegisterService.getRegisterForANM(anmIdentifier); return new ResponseEntity<>(ecRegisterMapper.mapToDTO(ecRegister), 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 shouldGetECRegisterForGivenANM() throws Exception { ECRegister ecRegister = new ECRegister(asList(new ECRegisterEntry() .withECNumber("123") .withRegistrationDate("2013-01-01") .withWifeName("wifeName") .withHusbandName("husbandName") .withVillage("village") .withSubCenter("sc") .withPHC("phc") .withWifeAge("23") .withHusbandAge("32") .withHouseholdNumber("22") .withHouseholdAddress("HH Address") .withHeadOfHousehold("Head of HH") .withReligion("religion") .withCaste("caste") .withEconomicStatus("bpl") .withWifeEducationLevel("wife education level") .withHusbandEducationLevel("husband education level") .withGravida("2") .withParity("1") .withNumberOfLivingChildren("1") .withNumberOfLivingMaleChildren("0") .withNumberOfLivingFemaleChildren("1") .withNumberOfStillBirths("0") .withNumberOfAbortions("1") .withYoungestChildAge("1") .withCurrentFPMethod("ocp") .withCurrentFPMethodStartDate("2012-01-01") .withPregnancyStatus(false) )); ECRegisterDTO expectedECRegisterDTO = new ECRegisterDTO(asList(new ECRegisterEntryDTO() .withECNumber("123") .withRegistrationDate("2013-01-01") .withWifeName("wifeName") .withHusbandName("husbandName") .withVillage("village") .withSubCenter("sc") .withPHC("phc") .withWifeAge("23") .withHusbandAge("32") .withHouseholdNumber("22") .withHouseholdAddress("HH Address") .withHeadOfHousehold("Head of HH") .withReligion("religion") .withCaste("caste") .withEconomicStatus("bpl") .withWifeEducationLevel("wife education level") .withHusbandEducationLevel("husband education level") .withGravida("2") .withParity("1") .withNumberOfLivingChildren("1") .withNumberOfLivingMaleChildren("0") .withNumberOfLivingFemaleChildren("1") .withNumberOfStillBirths("0") .withNumberOfAbortions("1") .withYoungestChildAge("1") .withCurrentFPMethod("ocp") .withCurrentFPMethodStartDate("2012-01-01") .withPregnancyStatus("no") )); when(ecRegisterService.getRegisterForANM("anm1")).thenReturn(ecRegister); when(ecRegisterMapper.mapToDTO(ecRegister)).thenReturn(expectedECRegisterDTO); ResponseEntity<ECRegisterDTO> response = controller.ecRegister("anm1"); assertEquals(expectedECRegisterDTO, response.getBody()); assertEquals(HttpStatus.OK, response.getStatusCode()); }