@Override public void perform() { given(). then(). statusCode(Status.UNAUTHORIZED.getStatusCode()). when(). get(whoAmIURL.toExternalForm()); } }).inspect(new SetupAuth(null));
@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(). post(testURL.toExternalForm()); } }).inspect(new SetupAuth(new User("testuser")));
@Override public void perform() { given(). then(). statusCode(Status.UNAUTHORIZED.getStatusCode()). when(). delete(testURL.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/"); }
@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 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(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(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"); } }
@Test @InSequence(11) public void verifyNotFoundForDeletedUser() throws Exception { assertNotNull("Previous step failed", uri_userInstance); given(). then(). // Few Containers support custom 404 media types. 404's are overwritten by default error page. //contentType(USER_MEDIA_TYPE). statusCode(Status.NOT_FOUND.getStatusCode()). when(). get(uri_userInstance); }
@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(12) public void shouldBeAbleToDeleteConference() throws Exception { assertNotNull("Previous step failed", uri_conferenceInstance); given(). then(). statusCode(Status.NO_CONTENT.getStatusCode()). when(). delete(uri_conferenceInstance); }
@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 shouldReturnNotFoundOnDELETEMissingResource() throws Exception { given(). contentType(getBaseMediaType()). then(). statusCode(Response.Status.NOT_FOUND.getStatusCode()). when(). delete(createRootURL() + "/{id}", "MISSING"); }
@Test @InSequence(3) public void shouldBeAbleToUpdateConference() throws Exception { assertNotNull("Previous step failed", uri_conferenceInstance); ConferenceType conf = getUpdateConference(); given(). contentType(CONFERENCE_MEDIA_TYPE). body(conf). then(). statusCode(Status.NO_CONTENT.getStatusCode()). when(). put(uri_conferenceInstance); }
@Test @InSequence(3) public void shouldBeAbleToUpdateUser() throws Exception { assertNotNull("Previous step failed", uri_userInstance); UserType conf = getUpdateUser(); given(). contentType(USER_MEDIA_TYPE). body(conf). then(). statusCode(Status.NO_CONTENT.getStatusCode()). when(). put(uri_userInstance); }