GetMethod getMethod =
executeGet(getUriBuilder(PageResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
TestConstants.TEST_PAGE_NAME).toString());
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Tags tags = objectFactory.createTags();
Tag tag = objectFactory.createTag();
tag.setName(tagName);
tags.getTags().add(tag);
PutMethod putMethod =
executePutXml(getUriBuilder(PageTagsResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
TestConstants.TEST_PAGE_NAME).toString(), tags, "Admin", "admin");
Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());
getMethod =
executeGet(getUriBuilder(PageTagsResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
TestConstants.TEST_PAGE_NAME).toString());
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
tags = (Tags) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
boolean found = false;
for (Tag t : tags.getTags()) {
if (tagName.equals(t.getName())) {
found = true;
break;
}
}
Assert.assertTrue(found);
getMethod = executeGet(getUriBuilder(TagsResource.class).build(getWiki()).toString());
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
tags = (Tags) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
found = false;
for (Tag t : tags.getTags()) {
if (tagName.equals(t.getName())) {
found = true;
break;
}
}