Search in sources :

Example 1 with Works

use of org.orcid.jaxb.model.record.summary_rc3.Works in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromPublicAPI.

@Test
public void testViewRecordFromPublicAPI() {
    ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        if (record.getActivitiesSummary() != null) {
            //Educations
            if (record.getActivitiesSummary().getEducations() != null) {
                Educations e = record.getActivitiesSummary().getEducations();
                if (e.getSummaries() != null) {
                    for (EducationSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Employments
            if (record.getActivitiesSummary().getEmployments() != null) {
                Employments e = record.getActivitiesSummary().getEmployments();
                if (e.getSummaries() != null) {
                    for (EmploymentSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Fundings
            if (record.getActivitiesSummary().getFundings() != null) {
                Fundings f = record.getActivitiesSummary().getFundings();
                List<FundingGroup> groups = f.getFundingGroup();
                if (groups != null) {
                    for (FundingGroup fGroup : groups) {
                        List<FundingSummary> summaries = fGroup.getFundingSummary();
                        if (summaries != null) {
                            for (FundingSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //PeerReviews
            if (record.getActivitiesSummary().getPeerReviews() != null) {
                PeerReviews p = record.getActivitiesSummary().getPeerReviews();
                List<PeerReviewGroup> groups = p.getPeerReviewGroup();
                if (groups != null) {
                    for (PeerReviewGroup pGroup : groups) {
                        List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                        if (summaries != null) {
                            for (PeerReviewSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //Works
            if (record.getActivitiesSummary().getWorks() != null) {
                Works w = record.getActivitiesSummary().getWorks();
                List<WorkGroup> groups = w.getWorkGroup();
                if (groups != null) {
                    for (WorkGroup wGroup : groups) {
                        List<WorkSummary> summaries = wGroup.getWorkSummary();
                        if (summaries != null) {
                            for (WorkSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertEquals(Visibility.PUBLIC, o.getVisibility());
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                assertEquals(Visibility.PUBLIC, b.getVisibility());
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            assertEquals(Visibility.PUBLIC, name.getVisibility());
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_rc4.Email) Keywords(org.orcid.jaxb.model.record_rc4.Keywords) Address(org.orcid.jaxb.model.record_rc4.Address) Fundings(org.orcid.jaxb.model.record.summary_rc4.Fundings) OtherNames(org.orcid.jaxb.model.record_rc4.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc4.PeerReviews) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) Name(org.orcid.jaxb.model.record_rc4.Name) Addresses(org.orcid.jaxb.model.record_rc4.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc4.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc4.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc4.FundingSummary) Biography(org.orcid.jaxb.model.record_rc4.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc4.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc4.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc4.Emails) Works(org.orcid.jaxb.model.record.summary_rc4.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc4.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc4.Keyword) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc4.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc4.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc4.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc4.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc4.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc4.EmploymentSummary) Test(org.junit.Test)

Example 2 with Works

use of org.orcid.jaxb.model.record.summary_rc3.Works in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromPublicAPI.

@Test
public void testViewRecordFromPublicAPI() {
    ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        if (record.getActivitiesSummary() != null) {
            //Educations
            if (record.getActivitiesSummary().getEducations() != null) {
                Educations e = record.getActivitiesSummary().getEducations();
                if (e.getSummaries() != null) {
                    for (EducationSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Employments
            if (record.getActivitiesSummary().getEmployments() != null) {
                Employments e = record.getActivitiesSummary().getEmployments();
                if (e.getSummaries() != null) {
                    for (EmploymentSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Fundings
            if (record.getActivitiesSummary().getFundings() != null) {
                Fundings f = record.getActivitiesSummary().getFundings();
                List<FundingGroup> groups = f.getFundingGroup();
                if (groups != null) {
                    for (FundingGroup fGroup : groups) {
                        List<FundingSummary> summaries = fGroup.getFundingSummary();
                        if (summaries != null) {
                            for (FundingSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //PeerReviews
            if (record.getActivitiesSummary().getPeerReviews() != null) {
                PeerReviews p = record.getActivitiesSummary().getPeerReviews();
                List<PeerReviewGroup> groups = p.getPeerReviewGroup();
                if (groups != null) {
                    for (PeerReviewGroup pGroup : groups) {
                        List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                        if (summaries != null) {
                            for (PeerReviewSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //Works
            if (record.getActivitiesSummary().getWorks() != null) {
                Works w = record.getActivitiesSummary().getWorks();
                List<WorkGroup> groups = w.getWorkGroup();
                if (groups != null) {
                    for (WorkGroup wGroup : groups) {
                        List<WorkSummary> summaries = wGroup.getWorkSummary();
                        if (summaries != null) {
                            for (WorkSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertEquals(Visibility.PUBLIC, o.getVisibility());
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                assertEquals(Visibility.PUBLIC, b.getVisibility());
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            assertEquals(Visibility.PUBLIC, name.getVisibility());
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_rc3.Email) Keywords(org.orcid.jaxb.model.record_rc3.Keywords) Address(org.orcid.jaxb.model.record_rc3.Address) Fundings(org.orcid.jaxb.model.record.summary_rc3.Fundings) OtherNames(org.orcid.jaxb.model.record_rc3.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc3.PeerReviews) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) Name(org.orcid.jaxb.model.record_rc3.Name) Addresses(org.orcid.jaxb.model.record_rc3.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc3.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc3.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc3.FundingSummary) Biography(org.orcid.jaxb.model.record_rc3.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc3.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc3.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc3.Emails) Works(org.orcid.jaxb.model.record.summary_rc3.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc3.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc3.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc3.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc3.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc3.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc3.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc3.EmploymentSummary) Test(org.junit.Test)

Example 3 with Works

use of org.orcid.jaxb.model.record.summary_rc3.Works in project ORCID-Source by ORCID.

the class WorksTest method testWorksWithPartOfRelationshipDontGetGrouped.

@Test
public void testWorksWithPartOfRelationshipDontGetGrouped() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    String accessTokenForClient1 = getAccessToken();
    String accessTokenForClient2 = getAccessToken(getUser1OrcidId(), getUser1Password(), getScopes(ScopePathType.ACTIVITIES_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED), getClient2ClientId(), getClient2ClientSecret(), getClient2RedirectUri());
    Work work1 = (Work) unmarshallFromPath("/record_2.0_rc3/samples/work-2.0_rc3.xml", Work.class);
    work1.setPutCode(null);
    work1.setVisibility(Visibility.PUBLIC);
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    org.orcid.jaxb.model.record_rc3.WorkTitle title1 = new org.orcid.jaxb.model.record_rc3.WorkTitle();
    title1.setTitle(new Title("Work # 1" + time));
    work1.setWorkTitle(title1);
    ExternalID wExtId1 = new ExternalID();
    wExtId1.setValue("Work Id " + time);
    wExtId1.setType(WorkExternalIdentifierType.AGR.value());
    wExtId1.setRelationship(Relationship.SELF);
    wExtId1.setUrl(new Url("http://orcid.org/work#1"));
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
    Work work2 = (Work) unmarshallFromPath("/record_2.0_rc3/samples/work-2.0_rc3.xml", Work.class);
    work2.setPutCode(null);
    work2.setVisibility(Visibility.PUBLIC);
    org.orcid.jaxb.model.record_rc3.WorkTitle title2 = new org.orcid.jaxb.model.record_rc3.WorkTitle();
    title2.setTitle(new Title("Work # 2" + time));
    work2.setWorkTitle(title2);
    work2.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId2 = new ExternalID();
    wExtId2.setValue("Work Id " + time);
    wExtId2.setType(WorkExternalIdentifierType.AGR.value());
    wExtId2.setRelationship(Relationship.PART_OF);
    wExtId2.setUrl(new Url("http://orcid.org/work#2"));
    work2.getExternalIdentifiers().getExternalIdentifier().clear();
    work2.getExternalIdentifiers().getExternalIdentifier().add(wExtId2);
    Work work3 = (Work) unmarshallFromPath("/record_2.0_rc3/samples/work-2.0_rc3.xml", Work.class);
    work3.setPutCode(null);
    work3.setVisibility(Visibility.PUBLIC);
    org.orcid.jaxb.model.record_rc3.WorkTitle title3 = new org.orcid.jaxb.model.record_rc3.WorkTitle();
    title3.setTitle(new Title("Work # 3" + time));
    work3.setWorkTitle(title3);
    work3.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId3 = new ExternalID();
    wExtId3.setValue("Work Id " + time);
    wExtId3.setType(WorkExternalIdentifierType.AGR.value());
    wExtId3.setRelationship(Relationship.SELF);
    wExtId3.setUrl(new Url("http://orcid.org/work#3"));
    work3.getExternalIdentifiers().getExternalIdentifier().clear();
    work3.getExternalIdentifiers().getExternalIdentifier().add(wExtId3);
    //Add the three works
    ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessTokenForClient1);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode1 = getPutCodeFromResponse(postResponse);
    postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work2, accessTokenForClient1);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode2 = getPutCodeFromResponse(postResponse);
    postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work3, accessTokenForClient2);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode3 = getPutCodeFromResponse(postResponse);
    ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(this.getUser1OrcidId(), accessTokenForClient1);
    assertEquals(Response.Status.OK.getStatusCode(), activitiesResponse.getStatus());
    ActivitiesSummary activities = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(activities);
    assertFalse(activities.getWorks().getWorkGroup().isEmpty());
    WorkGroup work1Group = null;
    WorkGroup work2Group = null;
    WorkGroup work3Group = null;
    boolean work1found = false;
    boolean work2found = false;
    boolean work3found = false;
    for (WorkGroup group : activities.getWorks().getWorkGroup()) {
        if (group.getIdentifiers().getExternalIdentifier() == null || group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            for (WorkSummary summary : group.getWorkSummary()) {
                String title = summary.getTitle().getTitle().getContent();
                if (("Work # 2" + time).equals(title)) {
                    work2found = true;
                    work2Group = group;
                }
            }
        } else {
            for (ExternalID id : group.getIdentifiers().getExternalIdentifier()) {
                //If it is the ID is the one we are looking for
                if (id.getValue().equals("Work Id " + time)) {
                    for (WorkSummary summary : group.getWorkSummary()) {
                        String title = summary.getTitle().getTitle().getContent();
                        if (("Work # 1" + time).equals(title)) {
                            work1found = true;
                            work1Group = group;
                        } else if (("Work # 3" + time).equals(title)) {
                            work3found = true;
                            work3Group = group;
                        }
                    }
                }
            }
        }
    }
    assertTrue(work1found);
    assertTrue(work2found);
    assertTrue(work3found);
    //Check that work # 1 and Work # 3 are in the same work
    assertEquals(work1Group, work3Group);
    //Check that work # 2 is not in the same group than group # 1
    assertThat(work2Group, not(work1Group));
    //Remove all created works
    ClientResponse deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode1, accessTokenForClient1);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode2, accessTokenForClient1);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode3, accessTokenForClient2);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalID(org.orcid.jaxb.model.record_rc3.ExternalID) WorkTitle(org.orcid.jaxb.model.record_rc3.WorkTitle) Title(org.orcid.jaxb.model.common_rc3.Title) TranslatedTitle(org.orcid.jaxb.model.common_rc3.TranslatedTitle) Url(org.orcid.jaxb.model.common_rc3.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) WorkGroup(org.orcid.jaxb.model.record.summary_rc3.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc3.WorkSummary) WorkTitle(org.orcid.jaxb.model.record_rc3.WorkTitle) WorkTitle(org.orcid.jaxb.model.record_rc3.WorkTitle) Work(org.orcid.jaxb.model.record_rc3.Work) Test(org.junit.Test)

Example 4 with Works

use of org.orcid.jaxb.model.record.summary_rc3.Works in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallWorks.

@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
    Works works = (Works) unmarshallFromPath("/record_2.0/samples/read_samples/works-2.0.xml", Works.class, "/record_2.0/activities-2.0.xsd");
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(3, works.getWorkGroup().size());
    boolean foundWorkWithNoExtIds = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertNotNull(group.getLastModifiedDate().getValue());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            WorkSummary summary = group.getWorkSummary().get(0);
            assertEquals("1", summary.getDisplayIndex());
            assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
            assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
            assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
            assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
            assertEquals("03", summary.getPublicationDate().getDay().getValue());
            assertEquals("03", summary.getPublicationDate().getMonth().getValue());
            assertEquals("2017", summary.getPublicationDate().getYear().getValue());
            assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
            assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
            assertEquals(Visibility.PUBLIC, summary.getVisibility());
            foundWorkWithNoExtIds = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
            if (extId.getType().equals("arxiv")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
                assertEquals("123456", extId.getValue());
            } else if (extId.getType().equals("bibcode")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
                assertEquals("4567", extId.getValue());
            } else {
                fail("Invalid ext id type " + extId.getType());
            }
            assertEquals(1, group.getWorkSummary().size());
            WorkSummary summary = group.getWorkSummary().get(0);
            if (summary.getPutCode().equals(Long.valueOf(3357))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
                assertEquals("02", summary.getPublicationDate().getDay().getValue());
                assertEquals("02", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else if (summary.getPutCode().equals(Long.valueOf(3358))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
                assertEquals("03", summary.getPublicationDate().getDay().getValue());
                assertEquals("03", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else {
                fail("Invalid put code " + summary.getPutCode());
            }
        }
    }
    assertTrue(foundWorkWithNoExtIds);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test)

Example 5 with Works

use of org.orcid.jaxb.model.record.summary_rc3.Works in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testUnmarshallWorks.

@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
    Works works = (Works) unmarshallFromPath("/record_2.1/samples/read_samples/works-2.1.xml", Works.class, "/record_2.1/activities-2.1.xsd");
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(3, works.getWorkGroup().size());
    boolean foundWorkWithNoExtIds = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertNotNull(group.getLastModifiedDate().getValue());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            WorkSummary summary = group.getWorkSummary().get(0);
            validateSourceInHttps(summary.getSource());
            assertEquals("1", summary.getDisplayIndex());
            assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
            assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
            assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
            assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
            assertEquals("03", summary.getPublicationDate().getDay().getValue());
            assertEquals("03", summary.getPublicationDate().getMonth().getValue());
            assertEquals("2017", summary.getPublicationDate().getYear().getValue());
            assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
            assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
            assertEquals(Visibility.PUBLIC, summary.getVisibility());
            foundWorkWithNoExtIds = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
            if (extId.getType().equals("arxiv")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
                assertEquals("123456", extId.getValue());
            } else if (extId.getType().equals("bibcode")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
                assertEquals("4567", extId.getValue());
            } else {
                fail("Invalid ext id type " + extId.getType());
            }
            assertEquals(1, group.getWorkSummary().size());
            WorkSummary summary = group.getWorkSummary().get(0);
            validateSourceInHttps(summary.getSource());
            if (summary.getPutCode().equals(Long.valueOf(3357))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
                assertEquals("02", summary.getPublicationDate().getDay().getValue());
                assertEquals("02", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else if (summary.getPutCode().equals(Long.valueOf(3358))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
                assertEquals("03", summary.getPublicationDate().getDay().getValue());
                assertEquals("03", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else {
                fail("Invalid put code " + summary.getPutCode());
            }
        }
    }
    assertTrue(foundWorkWithNoExtIds);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)35 Works (org.orcid.jaxb.model.record.summary_v2.Works)26 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)22 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)12 BaseTest (org.orcid.core.BaseTest)10 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)8 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)8 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)8 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)8 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)8 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)8 InputStream (java.io.InputStream)4 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 V2Convertible (org.orcid.core.version.V2Convertible)4 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)4 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)4 Address (org.orcid.jaxb.model.record_v2.Address)4 Email (org.orcid.jaxb.model.record_v2.Email)4