/** * Delete the given Order * * @param order the order to delete */ protected void deleteOrder(Order order) { // TODO Auto-generated method stub String url = getOrderUrl() + "/" + order.getId(); ClientResource cr = new ClientResource(url); ChallengeResponse chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password); cr.setChallengeResponse(chal); Representation result = cr.delete(getMediaTest()); assertNotNull(result); assertTrue(cr.getStatus().isSuccess()); Response response = getResponseOrderandUserstorage(getMediaTest(), result, Order.class); assertTrue(response.getSuccess()); result.release(); }
/** * Get the Order at the given url * * @param url the url where to find the Order * @return the Order found */ protected Order getOrder(String url) { ClientResource cr = new ClientResource(url); ChallengeResponse chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password); cr.setChallengeResponse(chal); Representation result = cr.get(getMediaTest()); assertNotNull(result); assertTrue(cr.getStatus().isSuccess()); Response response = getResponseOrderandUserstorage(getMediaTest(), result, Order.class); assertTrue(response.getSuccess()); result.release(); return (Order) response.getItem(); }
/** Assert if there are no Orders */ protected void assertNoneOrder() { ClientResource cr = new ClientResource(getOrderUrl()); ChallengeResponse chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password); cr.setChallengeResponse(chal); Representation result = cr.get(getMediaTest()); assertNotNull(result); assertTrue(cr.getStatus().isSuccess()); Response response = getResponseOrderandUserstorage(getMediaTest(), result, Order.class, true); assertTrue(response.getSuccess()); assertEquals(0, response.getTotal().intValue()); }
/** * Invoke POST * * @param item DataSet */ public void create(DataSet item) { Representation rep = GetRepresentationUtils.getRepresentationDataset(item, MediaType.APPLICATION_JSON); ClientResource cr = new ClientResource(getBaseUrl()); Representation result = cr.post(rep, MediaType.APPLICATION_JSON); assertTrue(cr.getStatus().isSuccess()); assertNotNull(result); Response response = getResponse(MediaType.APPLICATION_JSON, result, DataSet.class); assertTrue(response.getSuccess()); assertNotNull(response.getItem()); DataSet rs = (DataSet) response.getItem(); assertEquals(rs, item); RIAPUtils.exhaust(result); cr.release(); }
/** * Invoke an order and return the status returned * * @param urlAttach2 the url attachment of the resource * @return the TaskModel returned representing the status of the Task resource */ protected TaskModel invokeOrder(String urlAttach2, String parameters) { String url = getHostUrl() + PROJECT_URL + urlAttach2 + parameters; Representation result = null; try { ClientResource cr = new ClientResource(url); ChallengeResponse chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password); cr.setChallengeResponse(chal); result = cr.post(null, getMediaTest()); assertNotNull(result); assertTrue(cr.getStatus().isSuccess()); Response response = getResponse(getMediaTest(), result, TaskModel.class); assertTrue(response.getSuccess()); return (TaskModel) response.getItem(); } finally { RIAPUtils.exhaust(result); } }
private String getServicesDescription(String parentApplicationUrl) { String url = parentApplicationUrl + "/services"; System.out.println(url); Representation result = null; try { ClientResource cr = new ClientResource(url); result = cr.get(getMediaTest()); assertNotNull(result); assertTrue(cr.getStatus().isSuccess()); Response response = getResponse(getMediaTest(), result, ResourceModelDTO.class, true); assertTrue(response.getSuccess()); assertNotNull(response.getData()); assertEquals(1, response.getData().size()); ResourceModelDTO resDTO = (ResourceModelDTO) response.getData().get(0); List<ResourceParameter> parameters = resDTO.getParameters(); boolean found = false; String fileName = null; for (ResourceParameter resourceParameter : parameters) { if (resourceParameter.getName().equals("fileName")) { found = true; assertEquals("xs:template", resourceParameter.getValueType()); String value = resourceParameter.getValue(); assertFalse(value.contains("${date:")); fileName = resourceParameter.getValue(); break; } } if (!found) { fail("Parameter fileName not found"); } return fileName; } finally { RIAPUtils.exhaust(result); } }