BitIntegrityReportRest extends BaseRest { @Path("/{spaceId}") @GET public Response getReport(@PathParam("spaceId") String spaceId, @QueryParam("storeID") String storeId) { log.debug("getting report for {} , {} ", spaceId, storeId); return getReport(spaceId, storeId, false); } @Autowired  BitIntegrityReportRest(JpaBitIntegrityReportRepo repo,
                                  StorageProviderFactory storageProviderFactory); @Path("/{spaceId}") @GET Response getReport(@PathParam("spaceId") String spaceId,
                              @QueryParam("storeID") String storeId); @Path("/{spaceId}") @HEAD Response getReportHead(@PathParam("spaceId") String spaceId,
                                  @QueryParam("storeID") String storeId);  }
@Test public void testGetReport() { setupHeader(); setupBitIntegrityReportRepo(); setupStorageProviderFactory(); setupContentProperties(); setupGetContent(); replayAll(); createRest(); Response response = rest.getReport(spaceId, storeId); verifyHeaders(response); assertTrue(response.getEntity() instanceof InputStream); }
@Test public void testGetReportNoBitReportFound() { setupHeader(); expect(repo.findByStoreIdAndSpaceIdAndDisplayTrueOrderByCompletionDateDesc( eq(storeId), eq(spaceId), isA(PageRequest.class))) .andReturn(null); expect(storageProviderFactory.getStorageProvider(storeId)) .andReturn(store); expect(store.getSpaceACLs(spaceId)).andReturn(new HashMap<String, AclType>()); replayAll(); createRest(); Response response = rest.getReport(spaceId, storeId); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); }
@Test public void testGetReportInvalidSpace() { setupHeader(); expect(repo.findByStoreIdAndSpaceIdAndDisplayTrueOrderByCompletionDateDesc( eq(storeId), eq(spaceId), isA(PageRequest.class))) .andReturn(null); expect(storageProviderFactory.getStorageProvider(storeId)) .andReturn(store); expect(store.getSpaceACLs(spaceId)).andThrow(new NotFoundException("not found")); replayAll(); createRest(); Response response = rest.getReport(spaceId, storeId); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
@Test public void testGetReportError() { setupHeader(); expect(repo.findByStoreIdAndSpaceIdAndDisplayTrueOrderByCompletionDateDesc(eq(storeId), eq(spaceId), isA(PageRequest.class))) .andThrow(new RuntimeException("failure")); replayAll(); createRest(); Response response = rest.getReport(spaceId, storeId); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); }