Search in sources :

Example 21 with Education

use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.

the class AffiliationsManagerTest method getEducation.

private Education getEducation() {
    Education education = new Education();
    Organization org = new Organization();
    org.setName("org-name");
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("city");
    address.setCountry(Iso3166Country.US);
    org.setAddress(address);
    education.setOrganization(org);
    education.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
    education.setVisibility(Visibility.PUBLIC);
    return education;
}
Also used : Month(org.orcid.jaxb.model.common_v2.Month) Organization(org.orcid.jaxb.model.common_v2.Organization) Year(org.orcid.jaxb.model.common_v2.Year) Education(org.orcid.jaxb.model.record_v2.Education) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) Day(org.orcid.jaxb.model.common_v2.Day)

Example 22 with Education

use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.

the class AffiliationsManagerTest method testAddEducationToUnclaimedRecordPreserveEducationVisibility.

@Test
public void testAddEducationToUnclaimedRecordPreserveEducationVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Education education = getEducation();
    education = affiliationsManager.createEducationAffiliation(unclaimedOrcid, education, true);
    education = affiliationsManager.getEducationAffiliation(unclaimedOrcid, education.getPutCode());
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Education(org.orcid.jaxb.model.record_v2.Education) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 23 with Education

use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getEducation.

public Education getEducation() {
    Education education = new Education();
    education.setDepartmentName("department name");
    education.setEndDate(getFuzzyDate());
    education.setOrganization(getOrganization());
    education.setRoleTitle("role");
    education.setStartDate(getFuzzyDate());
    education.setVisibility(Visibility.PUBLIC);
    return education;
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education)

Example 24 with Education

use of org.orcid.jaxb.model.record_rc4.Education in project ORCID-Source by ORCID.

the class BlackBoxBase 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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Education(org.orcid.jaxb.model.record_v2.Education) Funding(org.orcid.jaxb.model.record_v2.Funding) Work(org.orcid.jaxb.model.record_v2.Work) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) IOException(java.io.IOException)

Example 25 with Education

use of org.orcid.jaxb.model.record_rc4.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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Education(org.orcid.jaxb.model.record_v2.Education) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)42 Education (org.orcid.jaxb.model.record_v2.Education)42 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Funding (org.orcid.jaxb.model.record_v2.Funding)8 Work (org.orcid.jaxb.model.record_v2.Work)8 Education (org.orcid.jaxb.model.record_rc1.Education)7 IOException (java.io.IOException)6 InputStreamReader (java.io.InputStreamReader)6 Reader (java.io.Reader)6 ArrayList (java.util.ArrayList)6 OtherName (org.orcid.jaxb.model.record_v2.OtherName)5 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)4 Education (org.orcid.jaxb.model.record_rc2.Education)4 Education (org.orcid.jaxb.model.record_rc3.Education)4 Education (org.orcid.jaxb.model.record_rc4.Education)4 Employment (org.orcid.jaxb.model.record_v2.Employment)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4