use of org.orcid.jaxb.model.record_v2.WorkBulk in project ORCID-Source by ORCID.
the class OrcidSecurityManager_WorkBulkTest method testMixedPublicAndLimitedWorkBulkReadPublicTokenMatchingSource.
@Test
public void testMixedPublicAndLimitedWorkBulkReadPublicTokenMatchingSource() {
WorkBulk workBulk = new WorkBulk();
workBulk.setBulk(Arrays.asList(createWork(Visibility.PUBLIC, CLIENT_2), createWork(Visibility.LIMITED, CLIENT_2)));
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_2, ScopePathType.READ_PUBLIC);
orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
assertNotNull(workBulk);
assertEquals(2, workBulk.getBulk().size());
}
use of org.orcid.jaxb.model.record_v2.WorkBulk in project ORCID-Source by ORCID.
the class OrcidSecurityManager_WorkBulkTest method testPrivateWorkBulkReadLimitedTokenMatchingSource.
@Test
public void testPrivateWorkBulkReadLimitedTokenMatchingSource() {
WorkBulk workBulk = new WorkBulk();
workBulk.setBulk(Arrays.asList(createWork(Visibility.PRIVATE, CLIENT_2)));
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_2, ScopePathType.READ_LIMITED);
orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
assertNotNull(workBulk);
assertEquals(1, workBulk.getBulk().size());
}
use of org.orcid.jaxb.model.record_v2.WorkBulk in project ORCID-Source by ORCID.
the class WorksTest method testCantAddMoreThan1000WorksAtATime.
@Test
public void testCantAddMoreThan1000WorksAtATime() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
WorkBulk bulk = createBulk(1001, null);
ClientResponse postResponse = memberV2ApiClient.createWorksJson(this.getUser1OrcidId(), bulk, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
OrcidError error = postResponse.getEntity(OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9006), error.getErrorCode());
}
use of org.orcid.jaxb.model.record_v2.WorkBulk in project ORCID-Source by ORCID.
the class WorksTest method testCreateBulkWithAllErrors.
@Test
public void testCreateBulkWithAllErrors() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
WorkBulk bulk = createBulk(10, "existing-ext-id-" + System.currentTimeMillis());
ClientResponse postResponse = memberV2ApiClient.createWorksJson(this.getUser1OrcidId(), bulk, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.OK.getStatusCode(), postResponse.getStatus());
bulk = postResponse.getEntity(WorkBulk.class);
assertNotNull(bulk);
assertNotNull(bulk.getBulk());
boolean first = true;
//All elements might be ok
for (BulkElement element : bulk.getBulk()) {
if (first) {
assertTrue(Work.class.isAssignableFrom(element.getClass()));
Work work = (Work) element;
//Remove the work
memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), work.getPutCode(), accessToken);
first = false;
} else {
assertTrue(OrcidError.class.isAssignableFrom(element.getClass()));
OrcidError error = (OrcidError) element;
assertEquals(Integer.valueOf(9021), error.getErrorCode());
}
}
}
use of org.orcid.jaxb.model.record_v2.WorkBulk in project ORCID-Source by ORCID.
the class MemberV2ApiServiceVersionedDelegatorTest method testViewBulkWorksWithBadPutCode.
@Test
public void testViewBulkWorksWithBadPutCode() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0003", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewBulkWorks("0000-0000-0000-0003", "11,12,13,bad");
WorkBulk workBulk = (WorkBulk) response.getEntity();
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(4, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof Work);
// private work
assertTrue(workBulk.getBulk().get(2) instanceof Work);
// bad put code
assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
Aggregations