I have A,B,C,E,D services have collect all that service from controller by company id and return that service as response to WebUtils.writeJSONResponse. What ever service i am getting form services like aService and bService. I have to store List DTO Object and i have to set in the setters of that EntityListResponce and i have to send that response to WebUtils.writeJSONResponse.
@RequestMapping("/getAllEntitys.htm")
public void getAllEntities(HttpServletRequest request,
HttpServletResponse response) {
try {
ZSession zSession = getZSession(request);
Long companyId = zSession.getCompanyId();
EntityListResponce entityListResponce = new EntityListResponce();
List<ADTO> aList = aService.getAllA(companyId);
List<BDTO> bList = bService.getAllB(companyId);
List<CListDTO> cList = cService.getAllC(companyId);
List<DDTO> dDTO = dService.getAllD(companyId);
EDTO eDTO = eService.getEcompanyId);
entityListResponce.setADTO(aList );
entityListResponce.setBDTO(bList );
entityListResponce.setCDTO(cList );
entityListResponce.setDDTO(dDTO );
entityListResponce.setEDTO(eDTO );
WebUtils.writeJSONResponse(response,
getSerializer(request, EXCLUDE_FILES).deepSerialize(entityListResponce));
} catch (Exception e) {
writeException(request, response, e);
}
}
But i not able get proper output when i am debugging by Junit.
@Test
public void testAllEntities() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/getAllEntitys.htm");
MockHttpServletResponse response = new MockHttpServletResponse();
invoiceController.getAllEntities(request, response);
JSONArray jsonArr = getResponseJSONArray(response);
Assert.assertNotNull(jsonArr);
}
Please help me it is proper way to do or not.Thanks