use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testReadPublicScope_PeerReview.
@Test
public void testReadPublicScope_PeerReview() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
assertNotNull(r);
assertEquals(PeerReview.class.getName(), r.getEntity().getClass().getName());
r = serviceDelegator.viewPeerReviewSummary(ORCID, 9L);
assertNotNull(r);
assertEquals(PeerReviewSummary.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source of should work
serviceDelegator.viewPeerReview(ORCID, 10L);
serviceDelegator.viewPeerReviewSummary(ORCID, 10L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewPeerReview(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewPeerReviewSummary(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Limited where am the source of should work
serviceDelegator.viewPeerReview(ORCID, 11L);
serviceDelegator.viewPeerReviewSummary(ORCID, 11L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewPeerReview(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewPeerReviewSummary(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testAddWork.
@Test
public void testAddWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(1, summary.getWorks().getWorkGroup().size());
Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0));
Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
String title = "work # 1 " + System.currentTimeMillis();
Work work = Utils.getWork(title);
response = serviceDelegator.createWork("4444-4444-4444-4445", work);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long putCode = Utils.getPutCode(response);
response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(2, summary.getWorks().getWorkGroup().size());
boolean haveOld = false;
boolean haveNew = false;
for (WorkGroup group : summary.getWorks().getWorkGroup()) {
Utils.verifyLastModified(group.getLastModifiedDate());
assertNotNull(group.getWorkSummary());
assertNotNull(group.getWorkSummary().get(0));
WorkSummary workSummary = group.getWorkSummary().get(0);
Utils.verifyLastModified(workSummary.getLastModifiedDate());
assertNotNull(workSummary.getTitle());
assertNotNull(workSummary.getTitle().getTitle());
if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
haveOld = true;
} else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
// Delete them
serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testReadPublicScope_Works.
@Test
public void testReadPublicScope_Works() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewWork(ORCID, 11L);
assertNotNull(r);
assertEquals(Work.class.getName(), r.getEntity().getClass().getName());
r = serviceDelegator.viewWorkSummary(ORCID, 11L);
assertNotNull(r);
assertEquals(WorkSummary.class.getName(), r.getEntity().getClass().getName());
// Limited where source is me, should work
serviceDelegator.viewWork(ORCID, 12L);
serviceDelegator.viewWorkSummary(ORCID, 12L);
// Limited with other source should fail
try {
serviceDelegator.viewWork(ORCID, 14L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewWorkSummary(ORCID, 14L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source should work
serviceDelegator.viewWork(ORCID, 13L);
serviceDelegator.viewWorkSummary(ORCID, 13L);
// Private with other source should fail
try {
serviceDelegator.viewWork(ORCID, 15L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewWork(ORCID, 15L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicWorks.
@Test
public void testGetPublicWorks() {
Response r = serviceDelegator.viewWorks(ORCID);
assertNotNull(r);
Works works = (Works) r.getEntity();
assertNotNull(works);
assertNotNull(works.getLastModifiedDate());
assertNotNull(works.getLastModifiedDate().getValue());
assertNotNull(works.getWorkGroup());
assertEquals(1, works.getWorkGroup().size());
assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertNotNull(works.getWorkGroup().get(0).getWorkSummary());
assertEquals(Long.valueOf(11), works.getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertNotNull(works.getWorkGroup().get(0).getWorkSummary().get(0).getLastModifiedDate());
assertNotNull(works.getWorkGroup().get(0).getWorkSummary().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getWorks.
private Works getWorks(Visibility... vs) {
Works works = new Works();
for (Visibility v : vs) {
WorkGroup g = new WorkGroup();
WorkSummary s = new WorkSummary();
s.setVisibility(v);
g.getWorkSummary().add(s);
works.getWorkGroup().add(g);
}
return works;
}
Aggregations