@SuppressWarnings("unchecked") @Test public void testProvision() { Map<String, String> requestBody = new HashMap<String, String>(); requestBody.put(OnboardingResource.STATE_EDORG_ID, "TestOrg"); requestBody.put(ResourceConstants.ENTITY_METADATA_TENANT_ID, "12345"); requestBody.put(OnboardingResource.PRELOAD_FILES_ID, "small_sample_dataset"); LandingZoneInfo landingZone = new LandingZoneInfo("LANDING ZONE", "INGESTION SERVER"); Map<String, String> tenantBody = new HashMap<String, String>(); tenantBody.put("landingZone", "LANDING ZONE"); tenantBody.put("ingestionServer", "INGESTION SERVER"); try { when(mockTenantResource.createLandingZone(Mockito.anyString(), Mockito.eq("TestOrg"), Mockito.anyBoolean())).thenReturn(landingZone); } catch (TenantResourceCreationException e) { Assert.fail(e.getMessage()); } Response res = resource.provision(requestBody, null); assertTrue(Status.fromStatusCode(res.getStatus()) == Status.CREATED); Map<String, String> result = (Map<String, String>) res.getEntity(); assertNotNull(result.get("landingZone")); Assert.assertEquals("LANDING ZONE", result.get("landingZone")); assertNotNull(result.get("serverName")); Assert.assertEquals("landingZone", result.get("serverName")); res = resource.provision(requestBody, null); assertEquals(Status.CREATED, Status.fromStatusCode(res.getStatus())); }
@POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; }
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } }
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired  OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); }
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired  OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); }
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired  OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); static final String STATE_EDUCATION_AGENCY; static final String STATE_EDORG_ID; static final String EDORG_INSTITUTION_NAME; static final String ADDRESSES; static final String ADDRESS_STREET; static final String ADDRESS_CITY; static final String ADDRESS_STATE_ABRV; static final String ADDRESS_POSTAL_CODE; static final String CATEGORIES; static final String PRELOAD_FILES_ID; }