RegisterController { @RequestMapping(method = GET, value = "/registers/child") @ResponseBody public ResponseEntity<ChildRegisterDTO> childRegister(@RequestParam("anm-id") String anmIdentifier) { ChildRegister childRegister = childRegisterService.getRegisterForANM(anmIdentifier); return new ResponseEntity<>(childRegisterMapper.mapToDTO(childRegister), 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 shouldGetChildRegisterForGivenANM() throws Exception { Map<String, String> immunizations = create("bcg", "2013-01-01") .put("opv_0", "2013-01-01") .put("hepb_0", "2013-01-01") .put("opv_1", "2013-01-01") .put("pentavalent_1", "2013-01-01") .put("opv_2", "2013-01-01") .put("pentavalent_2", "2013-01-01") .put("opv_3", "2013-01-01") .put("pentavalent_3", "2013-01-01") .put("measles", "2013-01-01") .put("je", "2013-01-01") .put("mmr", "2013-01-01") .put("dptbooster_1", "2013-01-01") .put("dptbooster_2", "2013-01-01") .put("opvbooster", "2013-01-01") .put("measlesbooster", "2013-01-01") .put("je_2", "2013-01-01") .map(); Map<String, String> vitaminADoses = create("1", "2013-01-01") .put("2", "2013-01-01") .map(); ChildRegister childRegister = new ChildRegister(asList(new ChildRegisterEntry() .withThayiCardNumber("thayi card number 1") .withWifeName("name1") .withHusbandName("name2") .withDOB("2013-01-01") .withVillage("village1") .withSubCenter("subCenter1") .withWifeDOB("1989-01-01") .withImmunizations(immunizations) .withVitaminADoses(vitaminADoses))); ChildRegisterDTO expectedChildRegisterDTO = new ChildRegisterDTO(asList(new ChildRegisterEntryDTO() .withThayiCardNumber("thayi card number 1") .withWifeName("name1") .withHusbandName("name2") .withDOB("2013-01-01") .withVillage("village1") .withSubCenter("subCenter1") .withWifeDOB("1989-01-01") .withImmunizations(immunizations) .withVitaminADoses(vitaminADoses))); when(childRegisterService.getRegisterForANM("anm1")).thenReturn(childRegister); when(childRegisterMapper.mapToDTO(childRegister)).thenReturn(expectedChildRegisterDTO); ResponseEntity<ChildRegisterDTO> response = controller.childRegister("anm1"); assertEquals(expectedChildRegisterDTO, response.getBody()); assertEquals(HttpStatus.OK, response.getStatusCode()); }