@Test public void testGetExtractResponse() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext context = new HttpRequestContextAdapter() { @Override public String getMethod() { return "GET"; } }; Response res = bulkExtract.getEdOrgExtractResponse(context, null, null); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf(INPUT_FILE_NAME) > 0); Object entity = res.getEntity(); assertNotNull(entity); StreamingOutput out = (StreamingOutput) entity; ByteArrayOutputStream os = new ByteArrayOutputStream(); out.write(os); os.flush(); byte[] responseData = os.toByteArray(); String s = new String(responseData); assertEquals(BULK_DATA, s); }
Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }  }
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }  @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
                             @PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
                              @PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }  @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
                             @PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
                              @PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }