protected Response postNonRDFSource(String slug, String file, String mimeType) throws IOException { // Make sure we can post binary resources return buildBaseRequestSpecification() .header(SLUG, slug) .body(IOUtils.toByteArray(getClass().getResourceAsStream("/" + file))) .contentType(mimeType) .expect() .statusCode(HttpStatus.SC_CREATED) .header(LOCATION, HeaderMatchers.headerPresent()) .when() .post(container); }
public static Response sendHttpGet(String contentType, String httpGetCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .log().all() .expect() .log().all() .when() .get(httpGetCommand); } return given() .contentType(contentType) .log().all() .when() .get(httpGetCommand); }
@Test(priority = 11) public void testForbiddenDeleteEmptyCollectionRelationship() throws Exception { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body("{\"data\":[]}") .delete("/parent/4/children/4/relationships/parents") .then() .statusCode(HttpStatus.SC_FORBIDDEN); }
@Test public void validateConnectionUiSpecs() throws Exception { UiSpecsPropertiesDto propertiesDto = buildTestDataStoreFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(propertiesDto) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/check")// .then()// .statusCode(HttpStatus.OK.value()).log().ifError()// .assertThat().body(notNullValue())// .assertThat().body(instanceOf(String.class)); }
protected static void assertCreateUser(User user){ given() .contentType("application/json;charset=UTF-8") .accept("application/json") .body(user) .expect().log().ifError() .statusCode(HttpStatus.SC_CREATED) .when() .post(getHost() + CONTEXT_PATH + "/users"); }
@Test public void validateConnectionJsonio() throws Exception { SerPropertiesDto propertiesDto = buildTestDataStoreSerProps(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(propertiesDto) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/check")// .then()// .statusCode(HttpStatus.OK.value()).log().ifError() // .assertThat().body(notNullValue())// .assertThat().body(instanceOf(String.class)); }
@Test(priority = 11) public void testNoDeleteExcludedRelationship() throws Exception { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body("{\"data\":{\"type\":\"excludedRelationship\",\"id\":\"1\"}}") .delete("/parent/4/children/4/relationships/excludedRelationship") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
public static Response sendHttpGet(String contentType, String httpGetCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .log().all() .expect() .log().all() .when() .get(httpGetCommand); } return given() .contentType(contentType) .log().all() .when() .get(httpGetCommand); }
public static Response sendHttpPost(String contentType, String payload, String httpPostCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .body(payload) .log().all() .expect() .log().all() .when() .post(httpPostCommand); } return given() .contentType(contentType) .body(payload) // .log().all() .when() .post(httpPostCommand); }
@Test public void getDatasetSchemaJsonIo() throws Exception { // given SerPropertiesDto formDataContainer = buildTestDataSetSerProps(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/schema")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getSchemaJsonRepresentation())); }
@Test(priority = 3) public void testPatchAttrList() throws Exception { String request = jsonParser.getJson("/ResourceIT/testPatchAttrList.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/parent/3") .then() .statusCode(HttpStatus.SC_BAD_REQUEST); }
public static Response sendHttpPost(String contentType, Map<String, ?> parameters, String httpPostCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .formParameters(parameters) .log().all() .expect() .log().all() .when() .post(httpPostCommand); } return given() .contentType(contentType) .formParameters(parameters) // .log().all() .when() .post(httpPostCommand); }
public static Response sendHttpPost(String contentType, String payload, String httpPostCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .body(payload) .log().all() .expect() .log().all() .when() .post(httpPostCommand); } return given() .contentType(contentType) .body(payload) // .log().all() .when() .post(httpPostCommand); }
@Test public void getDatasetSchemaUiSpec() throws Exception { // given UiSpecsPropertiesDto formDataContainer = buildTestDataSetFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/schema")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getSchemaJsonRepresentation())); }
@Test public void createChildNonRootable() { String request = jsonParser.getJson("/ResourceIT/createChildNonRootable.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .post("/child") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
public static Response sendHttpPost(String contentType, Map<String, ?> parameters, String httpPostCommand, boolean responseLog) { if (responseLog) { return given() .contentType(contentType) .formParameters(parameters) .log().all() .expect() .log().all() .when() .post(httpPostCommand); } return given() .contentType(contentType) .formParameters(parameters) // .log().all() .when() .post(httpPostCommand); }
/** * Attempts to create a new resource using PUT. * * @return the location of the created resource * @see #testPutToCreate() * @see #testRestrictPutReUseUri() */ protected String putToCreate() { // Build a unique URI for the PUT request. URI target = UriBuilder.fromUri(getResourceUri()) .path(UUID.randomUUID().toString()).build(); Model model = postContent(); Response response = buildBaseRequestSpecification().contentType(TEXT_TURTLE) .body(model, new RdfObjectMapper("")).expect() .statusCode(HttpStatus.SC_CREATED).when().put(target); String location = response.getHeader(LOCATION); if (location == null) { return target.toString(); } return location; }
@Test public void getDatasetDataUisSpecs() throws Exception { // given UiSpecsPropertiesDto formDataContainer = buildTestDataSetFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/data")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getRecordJsonRepresentation())); }
@Test(priority = 34) public void testPostToRecord() { String createRoot = jsonParser.getJson("/ResourceIT/createOneToOneRoot.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(createRoot) .post("/oneToOneRoot/1") .then() .statusCode(HttpStatus.SC_BAD_REQUEST); }
protected static void deleteUserFromCredentials(String userId, String username, String password) { given() .header("X-Requested-With", "XMLHttpRequest") .auth() .preemptive() .basic(username, password) .contentType("application/json;charset=UTF-8") .accept("application/json") .expect() .when() .delete(getHost() + CONTEXT_PATH + MONITORING_PATH + userId); }