protected void expectPut4xxConstrainedBy(String invalidProp) { Response putResponse = expectPut4xxStatus(invalidProp); final String uri = getResourceUri(); String constrainedBy = getFirstLinkForRelation(uri, LINK_REL_CONSTRAINEDBY, uri, putResponse); assertNotNull(constrainedBy, "Response did not contain a Link header with rel=\"http://www.w3.org/ns/ldp#constrainedBy\""); // Make sure we can GET the constrainedBy link. buildBaseRequestSpecification() .expect() .statusCode(isSuccessful()) .when() .get(constrainedBy); }
@Override public void perform() { given(). then(). statusCode(Status.OK.getStatusCode()). when(). get(testURL.toExternalForm()); } }).inspect(new SetupAuth(null));
@Override public void perform() { given(). then(). statusCode(Status.OK.getStatusCode()). when(). get(testURL.toExternalForm()); } }).inspect(new SetupAuth(new User("testuser")));
@Override public void perform() { given(). then(). statusCode(Status.UNAUTHORIZED.getStatusCode()). when(). get(whoAmIURL.toExternalForm()); } }).inspect(new SetupAuth(null));
@Test public void shouldAssambleRootResourcesXML() throws Exception { given(). then(). contentType(ROOT_XML_MEDIA_TYPE). body("root.link[0].@rel", equalTo("test")). body("root.link[0].@href", equalTo(new URL(baseURL, "api/test").toExternalForm())). when(). get(baseURL + "api/"); }
@Test public void shouldAssambleRootResourcesJSON() throws Exception { given(). then(). contentType(ROOT_JSON_MEDIA_TYPE). body("link[0].rel", equalTo("test")). body("link[0].href", equalTo(new URL(baseURL, "api/test").toExternalForm())). when(). get(baseURL + "api/"); }
@Test public void shouldProvideBookmarkLinkToResource() throws Exception { given(). contentType(TEST_MEDIA_TYPE). then(). contentType(TEST_MEDIA_TYPE). statusCode(Response.Status.OK.getStatusCode()). body("test.link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). body("test.link.@href", equalTo(new URL(baseURL, "api/bookmark/test/200").toExternalForm())). when(). get(baseURL + "api/test/200"); }
@Override public void perform() { given(). redirects(). follow(false). then(). statusCode(Status.SEE_OTHER.getStatusCode()). when(). get(whoAmIURL.toExternalForm()); } }).inspect(new SetupAuth(new User("testuser")));
@Test public void shouldRedirectToResource() throws Exception { given(). redirects(). follow(false). then(). statusCode(Response.Status.TEMPORARY_REDIRECT.getStatusCode()). header("Location", new URL(baseURL, "api/test/200").toExternalForm()). when(). get(baseURL + "api/bookmark/test/200"); }
@Test @InSequence(0) public void shouldNotBeAbleToLocateAttachmentRoot() throws Exception { given(). then(). contentType(BASE_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("root"). body("link.find {it.@rel == 'attachment'}.size()", equalTo(0)). when(). get(new URL(base, "api/").toExternalForm()). body(); }
@Test @InSequence(0) public void shouldNotBeAbleToLocateUserRoot() throws Exception { given(). then(). contentType(BASE_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("root"). body("link.find {it.@rel == 'user'}.size()", equalTo(0)). when(). get(new URL(base, "api/").toExternalForm()). body(); }
@Test @InSequence(4) public void shouldNotBeAbleToFindRelationAfterDelete() throws Exception { given(). then(). statusCode(Status.NO_CONTENT.getStatusCode()). when(). get(baseURL + "api/rel/{sourceObj}/{source}/{rel}/{targetObj}", "sourceobject", SOURCE_ID, type, "targetobject"); } }
protected static UserDTO assertUserExists(String path){ Response response = given() .expect().log().ifError() .statusCode(HttpStatus.SC_OK) .when() .get(getHost() + CONTEXT_PATH + path + JSON_SUFFIX); return deserialize(response.getBody().asString()); } }
@Test @InSequence(11) public void verifyNotFoundForDeletedSession() throws Exception { assertNotNull("Previous step failed", uri_sessionInstance); given(). then(). statusCode(Status.NOT_FOUND.getStatusCode()). when(). get(uri_sessionInstance); }
@Test @InSequence(11) public void verifyNotFoundForDeletedAttachment() throws Exception { assertNotNull("Previous step failed", uri_attachmentInstance); given(). then(). // Few Containers support custom 404 media types. 404's are overwritten by default error page. //contentType(CONFERENCE_MEDIA_TYPE). statusCode(Status.NOT_FOUND.getStatusCode()). when(). get(uri_attachmentInstance); }
@Test @InSequence(6) public void shouldBeAbleToGetSessionsForAConference() throws Exception { assertNotNull("Previous step failed", uri_session); given(). then(). contentType(SESSION_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("collection"). body("session.size()", equalTo(1)). when(). get(uri_session); }
@Test @InSequence(2) public void shouldBeAbleToGetUser() throws Exception { assertNotNull("Previous step failed", uri_userInstance); given(). then(). contentType(USER_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). when(). get(uri_userInstance); }
@Test public void shouldReturnNotFoundOnGETMissingResource() throws Exception { given(). contentType(getBaseMediaType()). then(). statusCode(Response.Status.NOT_FOUND.getStatusCode()). when(). get(createRootURL() + "/{id}", "MISSING"); }
@Test public void testGetConnectors_badDefinition() throws Exception { given().expect() // .statusCode(400) // .log().ifValidationFails() // // TODO: check returned error .body(Matchers.containsString("definitionClass")) // .get(getVersionPrefix() + "/properties/{name}/connectors", DATA_SET_DEFINITION_NAME); }
@Test @InSequence(2) public void shouldBeAbleToGetAttachment() throws Exception { assertNotNull("Previous step failed", uri_attachmentInstance); given(). then(). contentType(ATTACHMENT_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). when(). get(uri_attachmentInstance). body(). path("attachment.link.find {it.@rel == 'session'}.@href"); }