use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateEducation_validEducationTest.
@Test
public void validateEducation_validEducationTest() {
Education education = getEducation();
activityValidator.validateEducation(education, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.
the class BlackBoxBaseRC2 method unmarshallFromPath.
public Object unmarshallFromPath(String path, Class<?> type) {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type);
Object result = null;
if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Funding.class.equals(type)) {
result = (Funding) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Work.class.equals(type)) {
result = (Work) obj;
} else if (PeerReview.class.equals(type)) {
result = (PeerReview) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.
the class PublicV2Test method checkEducation.
public void checkEducation(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
Education educationToCreate = (Education) unmarshallFromPath("/record_2.0_rc1/samples/education-2.0_rc1.xml", Education.class);
educationToCreate.setPutCode(null);
educationToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createEducationXml(getUser1OrcidId(), educationToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String path = postResponse.getLocation().getPath();
String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
ClientResponse getEducationResponse = null;
if (readPublicToken != null) {
getEducationResponse = publicV2ApiClient.viewEducationXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getEducationResponse = publicV2ApiClient.viewEducationXml(getUser1OrcidId(), putCode);
}
assertNotNull(getEducationResponse);
checkResponse(getEducationResponse);
Education education = getEducationResponse.getEntity(Education.class);
assertNotNull(education);
assertEquals("education:department-name", education.getDepartmentName());
ClientResponse getEducationSummaryResponse = null;
if (readPublicToken != null) {
getEducationSummaryResponse = publicV2ApiClient.viewEducationSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getEducationSummaryResponse = publicV2ApiClient.viewEducationSummaryXml(getUser1OrcidId(), putCode);
}
assertNotNull(getEducationSummaryResponse);
checkResponse(getEducationSummaryResponse);
EducationSummary summary = getEducationSummaryResponse.getEntity(EducationSummary.class);
assertNotNull(summary);
assertEquals("education:department-name", summary.getDepartmentName());
}
use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.
the class MemberV2_1Test method testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Education education = (Education) unmarshallFromPath("/record_2.1/samples/read_samples/education-2.1.xml", Education.class);
education.setPutCode(null);
education.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2_1ApiClient.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.1/" + this.getUser1OrcidId() + "/education/\\d+"));
ClientResponse getResponse = memberV2_1ApiClient.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 = memberV2_1ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEducation);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2_1ApiClient.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 = memberV2_1ApiClient.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.
the class BlackBoxBaseV2_1Release method unmarshallFromPath.
public Object unmarshallFromPath(String path, Class<?> type) {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type);
Object result = null;
if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Funding.class.equals(type)) {
result = (Funding) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Work.class.equals(type)) {
result = (Work) obj;
} else if (PeerReview.class.equals(type)) {
result = (PeerReview) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
Aggregations