@Override protected ResponseSpecification responseValidation(ResponseSpecification spec, User user) { return spec. root("user"). body("name", equalTo(user.getName())). body("bio", equalTo(user.getBio())); } }
@Override protected ResponseSpecification responseValidation(ResponseSpecification spec, Attachment attachment) { return spec. root("attachment"). body("title", equalTo(attachment.getTitle())). body("mimeType", equalTo(attachment.getMimeType())). body("url", equalTo(attachment.getUrl().toExternalForm())); } }
@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(); }
@Override public void perform() { given(). then(). contentType(BASE_XML_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("source"). body("link.find {it.@rel == 'connections'}.size()", equalTo(1)). body("link.find {it.@rel == 'notdeployed'}.size()", equalTo(0)). when(). get(baseURL + "api/source/{id}", SOURCE_ID); } }).inspect(new ValueInjectionInspection(target, source));
@Test @InSequence(7) public void shouldBeAbleToGetSession() throws Exception { assertNotNull("Previous step failed", uri_sessionInstance); given(). then(). contentType(SESSION_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("session"). body("link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). body("link.find {it.@rel == 'self'}.size()", equalTo(1)). body("link.find {it.@rel == 'parent'}.size()", equalTo(1)). when(). get(uri_sessionInstance); }
@Test @InSequence(0) public void shouldBeAbleToLocateConferenceRoot() throws Exception { //uri_conference = new URL(base, "api/conference").toExternalForm(); uri_conference = given(). then(). contentType(BASE_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("root"). body("link.find {it.@rel == 'conference'}.size()", equalTo(1)). when(). get(new URL(base, "api/").toExternalForm()). body(). path("root.link.find {it.@rel == 'conference'}.@href"); }
@Test public void shouldProvideBookmarkLinkToCollectionResource() throws Exception { given(). contentType(TEST_MEDIA_TYPE). then(). contentType(TEST_MEDIA_TYPE). statusCode(Response.Status.OK.getStatusCode()). root("collection"). body("test[0].link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). body("test[1].link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). when(). get(baseURL + "api/test/all"); } }
@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(4) public void verifyUpdatedUser() throws Exception { assertNotNull("Previous step failed", uri_userInstance); UserType conf = getUpdateUser(); given(). then(). contentType(USER_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("user"). body("name", equalTo(conf.getName())). body("bio", equalTo(conf.getBio())). body("handle", not(equalTo(conf.getHandle()))). // handle is the id, can not be updated when(). get(uri_userInstance); }
@Override protected ResponseSpecification responseValidation(ResponseSpecification spec, Conference conference) { return spec. root("conference"). body("name", equalTo(conference.getName())). body("tagLine", equalTo(conference.getTagLine())). body("start", equalToXmlDate(conference.getDuration().getStart())). body("end", equalToXmlDate(conference.getDuration().getEnd())); }
@Test @InSequence(4) public void verifyUpdatedAttachment() throws Exception { assertNotNull("Previous step failed", uri_attachmentInstance); AttachmentType conf = getUpdateAttachment(); given(). then(). contentType(ATTACHMENT_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("attachment"). body("title", equalTo(conf.getTitle())). body("mimeType", equalTo(conf.getMimeType())). when(). get(uri_attachmentInstance); }
@Test @InSequence(9) public void verifyUpdatedSession() throws Exception { assertNotNull("Previous step failed", uri_sessionInstance); SessionType session = getUpdateSession(); given(). then(). contentType(SESSION_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("session"). body("title", equalTo(session.getTitle())). body("outline", equalTo(session.getOutline())). when(). get(uri_sessionInstance); }
@Override protected ResponseSpecification responseValidation(ResponseSpecification spec, Session session) { return spec. root("session"). body("title", equalTo(session.getTitle())). body("outline", equalTo(session.getOutline())). body("start", equalToXmlDate(session.getDuration().getStart())). body("end", equalToXmlDate(session.getDuration().getEnd())); } }
@Test @InSequence(4) public void verifyUpdatedConference() throws Exception { assertNotNull("Previous step failed", uri_conferenceInstance); ConferenceType conf = getUpdateConference(); given(). then(). contentType(CONFERENCE_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("conference"). body("name", equalTo(conf.getName())). body("tagLine", equalTo(conf.getTagLine())). when(). get(uri_conferenceInstance); }
@Test @InSequence(2) public void shouldBeAbleToGetConference() throws Exception { assertNotNull("Previous step failed", uri_conferenceInstance); uri_session = given(). then(). contentType(CONFERENCE_MEDIA_TYPE). statusCode(Status.OK.getStatusCode()). root("conference"). body("link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). body("link.find {it.@rel == 'self'}.size()", equalTo(1)). when(). get(uri_conferenceInstance). body(). path("conference.link.find {it.@rel == 'session'}.@href"); }