use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.
the class MemberV2Test method testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Education education = (Education) unmarshallFromPath("/record_2.0/samples/read_samples/education-2.0.xml", Education.class);
education.setPutCode(null);
education.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createEducationXml(this.getUser1OrcidId(), education, 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/" + this.getUser1OrcidId() + "/education/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Education gotEducation = getResponse.getEntity(Education.class);
assertEquals("education:department-name", gotEducation.getDepartmentName());
assertEquals("education:role-title", gotEducation.getRoleTitle());
gotEducation.setDepartmentName("updated dept. name");
gotEducation.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEducation);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
assertEquals("education:department-name", gotAfterUpdateEducation.getDepartmentName());
assertEquals("education:role-title", gotAfterUpdateEducation.getRoleTitle());
ClientResponse deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getEducationMapperFacade.
public MapperFacade getEducationMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Education, OrgAffiliationRelationEntity> educationClassMap = mapperFactory.classMap(Education.class, OrgAffiliationRelationEntity.class);
addV2CommonFields(educationClassMap);
registerSourceConverters(mapperFactory, educationClassMap);
educationClassMap.fieldBToA("org.name", "organization.name");
educationClassMap.fieldBToA("org.city", "organization.address.city");
educationClassMap.fieldBToA("org.region", "organization.address.region");
educationClassMap.fieldBToA("org.country", "organization.address.country");
educationClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
educationClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
educationClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
educationClassMap.field("departmentName", "department");
educationClassMap.field("roleTitle", "title");
educationClassMap.register();
ClassMapBuilder<EducationSummary, OrgAffiliationRelationEntity> educationSummaryClassMap = mapperFactory.classMap(EducationSummary.class, OrgAffiliationRelationEntity.class);
addV2CommonFields(educationSummaryClassMap);
registerSourceConverters(mapperFactory, educationSummaryClassMap);
educationSummaryClassMap.fieldBToA("org.name", "organization.name");
educationSummaryClassMap.fieldBToA("org.city", "organization.address.city");
educationSummaryClassMap.fieldBToA("org.region", "organization.address.region");
educationSummaryClassMap.fieldBToA("org.country", "organization.address.country");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
educationSummaryClassMap.field("departmentName", "department");
educationSummaryClassMap.field("roleTitle", "title");
educationSummaryClassMap.register();
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewEducation.
@Test
public void testViewEducation() {
Response response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertNotNull(education.getLastModifiedDate());
assertNotNull(education.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(20), education.getPutCode());
assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
assertEquals("PUBLIC Department", education.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testGetPublicEducationUsingToken.
// Education
@Test
public void testGetPublicEducationUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(r);
Education e = (Education) r.getEntity();
assertNotNull(e);
assertNotNull(e.getLastModifiedDate());
assertNotNull(e.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(20), e.getPutCode());
}
use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducationLeavingVisibilityNullTest.
@Test
public void testUpdateEducationLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEducation("4444-4444-4444-4443", 3L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertEquals(Visibility.PUBLIC, education.getVisibility());
education.setVisibility(null);
response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
education = (Education) response.getEntity();
assertNotNull(education);
assertEquals(Visibility.PUBLIC, education.getVisibility());
}
Aggregations