### Question:
GetTotalPageCountAPIController { @RequestMapping(value = "/totalpagecount/{parentObjectType}/{parentObjectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public int getTotalPageCount(@PathVariable("parentObjectType") String parentObjectType, @PathVariable("parentObjectId") Long parentObjectId, @RequestParam(value = "fileTypes", required = false, defaultValue = "") String fileTypes, @RequestParam(value = "mimeTypes", required = false, defaultValue = "") String mimeTypes, Authentication auth) { List<String> fileTypesList = Arrays.asList(fileTypes.split("\\s*,\\s*")); List<String> mimeTypesList = Arrays.asList(mimeTypes.split("\\s*,\\s*")); LOG.debug("File types: {}", fileTypesList); LOG.debug("Mime types: {}", mimeTypesList); return getEcmFileService().getTotalPageCount(parentObjectType, parentObjectId, fileTypesList, mimeTypesList, auth); }  @RequestMapping(value = "/totalpagecount/{parentObjectType}/{parentObjectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody int getTotalPageCount(@PathVariable("parentObjectType") String parentObjectType,
            @PathVariable("parentObjectId") Long parentObjectId,
            @RequestParam(value = "fileTypes", required = false, defaultValue = "") String fileTypes,
            @RequestParam(value = "mimeTypes", required = false, defaultValue = "") String mimeTypes, Authentication auth); EcmFileService getEcmFileService(); void setEcmFileService(EcmFileService ecmFileService);  }### Answer:
@Test public void getTotalPageCountTest() throws Exception { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("json/TotalPageCountSolrResponse.json"); String searchResult = IOUtils.toString(inputStream, "UTF-8"); InputStream noResultsInputStream = getClass().getClassLoader().getResourceAsStream("json/NoResultsTotalPageCountSolrResponse.json"); String noResultsSearchResult = IOUtils.toString(noResultsInputStream, "UTF-8"); String query = SearchConstants.PROPERTY_OBJECT_TYPE + ":FILE AND " + SearchConstants.PROPERTY_FILE_TYPE + ":(authorization OR abstract) AND " + SearchConstants.PROPERTY_MIME_TYPE + ":application/pdf AND " + SearchConstants.PROPERTY_PARENT_OBJECT_TYPE_S + ":CASE_FILE AND " + SearchConstants.PROPERTY_PARENT_OBJECT_ID_I + ":10"; expect(mockAuthentication.getName()).andReturn("user"); expect(mockExecuteSolrQuery.getResultsByPredefinedQuery(mockAuthentication, SolrCore.QUICK_SEARCH, query, 0, 50, SearchConstants.PROPERTY_OBJECT_ID_S + " DESC")).andReturn(searchResult); expect(mockExecuteSolrQuery.getResultsByPredefinedQuery(mockAuthentication, SolrCore.QUICK_SEARCH, query, 50, 50, SearchConstants.PROPERTY_OBJECT_ID_S + " DESC")).andReturn(noResultsSearchResult); replayAll(); MvcResult result = mockMvc.perform( get("/api/latest/service/ecm/totalpagecount/{parentObjectType}/{parentObjectId}?fileTypes={fileTypes}&mimeTypes={mimeTypes}", "CASE_FILE", 10, "authorization,abstract", "application/pdf") .principal(mockAuthentication) .contentType(MediaType.APPLICATION_JSON)) .andReturn(); verifyAll(); closeInputStream(inputStream); LOG.info("Results: {}", result.getResponse().getContentAsString()); int totalPageCount = Integer.parseInt(result.getResponse().getContentAsString()); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertEquals(11, totalPageCount); }