use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testAddKeyword.
@Test
public void testAddKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.createKeyword("4444-4444-4444-4441", Utils.getKeyword());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewKeyword("4444-4444-4444-4441", putCode);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Keyword newKeyword = (Keyword) response.getEntity();
assertNotNull(newKeyword);
Utils.verifyLastModified(newKeyword.getLastModifiedDate());
assertEquals("New keyword", newKeyword.getContent());
assertEquals(Visibility.PUBLIC, newKeyword.getVisibility());
assertNotNull(newKeyword.getSource());
assertEquals("APP-5555555555555555", newKeyword.getSource().retrieveSourcePath());
assertNotNull(newKeyword.getCreatedDate());
Utils.verifyLastModified(newKeyword.getLastModifiedDate());
}
use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testViewPrivateKeyword.
@Test
public void testViewPrivateKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4443", 4L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
assertEquals("/4444-4444-4444-4443/keywords/4", keyword.getPath());
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertEquals("what else can we make?", keyword.getContent());
assertEquals(Visibility.PRIVATE, keyword.getVisibility());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testViewKeywordReadPublic.
@Test
public void testViewKeywordReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewKeyword(ORCID, 9L);
Keyword element = (Keyword) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/keywords/9", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeywordChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateKeywordChangingVisibilityTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
keyword.setVisibility(Visibility.PRIVATE);
response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
fail();
}
use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeyword.
@Test
public void testUpdateKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
LastModifiedDate before = keyword.getLastModifiedDate();
assertEquals("keyword-2", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
keyword.setContent("Updated keyword");
response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertTrue(keyword.getLastModifiedDate().after(before));
assertEquals("Updated keyword", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
Aggregations