use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewPrivateMembership.
@Test
public void testViewPrivateMembership() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewMembership(ORCID, 39L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
Utils.verifyLastModified(membership.getLastModifiedDate());
assertEquals(Long.valueOf(39L), membership.getPutCode());
assertEquals("/0000-0000-0000-0003/membership/39", membership.getPath());
assertEquals("PRIVATE Department", membership.getDepartmentName());
assertEquals(Visibility.PRIVATE.value(), membership.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipNoStartDate.
@Test(expected = OrcidValidationException.class)
public void testAddMembershipNoStartDate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
membership.setStartDate(null);
serviceDelegator.createMembership(ORCID, membership);
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testDeleteMembership.
@Test
public void testDeleteMembership() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1004L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
try {
serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
fail();
} catch (NoResultException nre) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateMembershipChangingVisibilityTest() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewMembership(ORCID, 37L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
assertEquals(Visibility.PUBLIC, membership.getVisibility());
membership.setVisibility(Visibility.PRIVATE);
response = serviceDelegator.updateMembership(ORCID, 37L, membership);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateMembershipYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewMembership(ORCID, 40L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
membership.setDepartmentName("Updated department name");
membership.setRoleTitle("The updated role title");
serviceDelegator.updateMembership(ORCID, 40L, membership);
fail();
}
Aggregations