@Test public void testSEADelta() throws Exception { String edOrgId = "Midvale"; Map<String, Object> edOrgBody = new HashMap<String, Object>(); List<String> orgCategory = new ArrayList<String>(); orgCategory.add("State Education Agency"); edOrgBody.put("organizationCategories", orgCategory); Entity edOrg = new MongoEntity(EntityNames.EDUCATION_ORGANIZATION, edOrgId, edOrgBody, null); when(edOrgHelper.byId(edOrgId)).thenReturn(edOrg); when(edOrgHelper.isSEA(edOrg)).thenReturn(true); DateTime d = ISODateTimeFormat.dateTime().parseDateTime("2013-05-14T11:00:00.000Z"); Date date = d.toDate(); mockBulkExtractEntity(date); Mockito.when(edOrgHelper.getDirectChildLEAsOfEdOrg(edOrg)).thenReturn(Arrays.asList("lea123")); Set<String> lea = new HashSet<String>(); lea.add("lea123"); Mockito.when(mockValidator.validate(EntityNames.EDUCATION_ORGANIZATION, lea)).thenReturn(lea); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList("lea123")); Entity mockAppAuth = Mockito.mock(Entity.class); Mockito.when(mockAppAuth.getBody()).thenReturn(authBody); Mockito.when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAppAuth); Response res = bulkExtract.getPublicDelta(req, CONTEXT, "2013-05-14T11:00:00.000Z"); assertEquals(200, res.getStatus()); }
@GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }  }
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }  @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 { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }  @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; }