use of org.orcid.jaxb.model.record_rc2.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_SomeLimited_NoSource_ReadLimitedToken.
@Test
public void testPersonalDetails_When_SomeLimited_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.LIMITED);
Biography bio = createBiography(Visibility.LIMITED);
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_2);
OtherName o3 = createOtherName(Visibility.LIMITED, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertEquals(name, p.getName());
assertEquals(bio, p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertTrue(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
use of org.orcid.jaxb.model.record_rc2.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testName_CantRead_When_DontHaveReadScope_IsPrivate.
@Test(expected = OrcidAccessControlException.class)
public void testName_CantRead_When_DontHaveReadScope_IsPrivate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_UPDATE);
Name name = createName(Visibility.PRIVATE);
orcidSecurityManager.checkAndFilter(ORCID_1, name, ScopePathType.ORCID_BIO_READ_LIMITED);
fail();
}
use of org.orcid.jaxb.model.record_rc2.Name in project ORCID-Source by ORCID.
the class RecordNameManagerTest method testFailOnCreatingOnARecordThatAlreadyHaveRecordName.
@Test(expected = IllegalArgumentException.class)
public void testFailOnCreatingOnARecordThatAlreadyHaveRecordName() {
Name name = new Name();
long time = System.currentTimeMillis();
name.setCreditName(new CreditName("Credit Name " + time));
name.setFamilyName(new FamilyName("Family Name " + time));
name.setGivenNames(new GivenNames("Given Names " + time));
name.setVisibility(Visibility.PRIVATE);
String orcid = "0000-0000-0000-0001";
recordNameManager.createRecordName(orcid, name);
fail();
}
use of org.orcid.jaxb.model.record_rc2.Name in project ORCID-Source by ORCID.
the class MemberV2Test method testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc2/samples/peer-review-2.0_rc2.xml", PeerReview.class);
peerReviewToCreate.setPutCode(null);
peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
peerReviewToCreate.setVisibility(Visibility.PUBLIC);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReviewToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc2/" + this.getUser1OrcidId() + "/peer-review/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
PeerReview gotPeerReview = getResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotPeerReview.getSubjectName().getTitle().getContent());
gotPeerReview.getSubjectName().getTitle().setContent("updated title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotPeerReview);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
PeerReview gotAfterUpdatePeerReview = getAfterUpdateResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotAfterUpdatePeerReview.getSubjectName().getTitle().getContent());
ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), gotAfterUpdatePeerReview.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc2.Name in project ORCID-Source by ORCID.
the class ValidateV2RC3SamplesTest method testUnmarshallName.
@Test
public void testUnmarshallName() throws SAXException, URISyntaxException {
Name name = (Name) unmarshallFromPath("/record_2.0_rc3/samples/name-2.0_rc3.xml", Name.class, "/record_2.0_rc3/personal-details-2.0_rc3.xsd");
assertNotNull(name);
assertNotNull(name.getCreditName());
assertEquals("credit-name", name.getCreditName().getContent());
assertNotNull(name.getFamilyName());
assertEquals("family-name", name.getFamilyName().getContent());
assertNotNull(name.getGivenNames());
assertEquals("given-names", name.getGivenNames().getContent());
assertNotNull(name.getVisibility());
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
Aggregations