Search in sources :

Example 76 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title in project ORCID-Source by ORCID.

the class JpaJaxbQualificationAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    Qualification e = getQualification();
    assertNotNull(e);
    OrgAffiliationRelationEntity oar = adapter.toOrgAffiliationRelationEntity(e);
    assertNotNull(oar);
    // General info
    assertEquals(Long.valueOf(0), oar.getId());
    assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
    assertEquals("department-name", oar.getDepartment());
    assertEquals("role-title", oar.getTitle());
    // Dates
    assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
    // Source
    assertNull(oar.getSourceId());
    assertNull(oar.getClientSourceId());
    assertNull(oar.getElementSourceId());
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 77 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title in project ORCID-Source by ORCID.

the class PublicProfileControllerTest method testViewValidUser.

@SuppressWarnings("unchecked")
@Test
public void testViewValidUser() {
    ModelAndView mav = publicProfileController.publicPreview(request, response, 1, 0, 15, userOrcid);
    assertEquals("public_profile_v3", mav.getViewName());
    Map<String, Object> model = mav.getModel();
    assertNotNull(model);
    assertTrue(model.containsKey("isPublicProfile"));
    assertTrue(model.containsKey("effectiveUserOrcid"));
    assertEquals(userOrcid, model.get("effectiveUserOrcid"));
    assertTrue(model.containsKey("biography"));
    Biography biography = (Biography) model.get("biography");
    assertEquals("Biography for 0000-0000-0000-0003", biography.getContent());
    assertTrue(model.containsKey("displayName"));
    String displayName = (String) model.get("displayName");
    assertEquals("Credit Name", displayName);
    assertTrue(model.containsKey("title"));
    assertEquals(localeManager.resolveMessage("layout.public-layout.title", displayName, userOrcid), model.get("title"));
    assertTrue(model.containsKey("publicGroupedOtherNames"));
    Map<String, List<OtherName>> groupedOtherNames = (Map<String, List<OtherName>>) model.get("publicGroupedOtherNames");
    assertNotNull(groupedOtherNames);
    assertEquals(1, groupedOtherNames.keySet().size());
    assertTrue(groupedOtherNames.containsKey("Other Name PUBLIC"));
    List<OtherName> publicOtherNames = groupedOtherNames.get("Other Name PUBLIC");
    assertEquals(1, publicOtherNames.size());
    assertEquals(Long.valueOf(13), publicOtherNames.get(0).getPutCode());
    assertEquals("Other Name PUBLIC", publicOtherNames.get(0).getContent());
    assertEquals(Visibility.PUBLIC, publicOtherNames.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedAddresses"));
    Map<String, List<Address>> groupedAddresses = (Map<String, List<Address>>) model.get("publicGroupedAddresses");
    assertNotNull(groupedAddresses);
    assertEquals(1, groupedAddresses.keySet().size());
    assertTrue(groupedAddresses.containsKey("US"));
    List<Address> publicAddresses = groupedAddresses.get("US");
    assertEquals(1, publicAddresses.size());
    assertEquals(Long.valueOf(9), publicAddresses.get(0).getPutCode());
    assertEquals(Iso3166Country.US, publicAddresses.get(0).getCountry().getValue());
    assertEquals(Visibility.PUBLIC, publicAddresses.get(0).getVisibility());
    assertTrue(model.containsKey("countryNames"));
    Map<String, String> countryNames = (Map<String, String>) model.get("countryNames");
    Map<String, String> testCountry = new HashMap<String, String>();
    testCountry.put("US", localeManager.resolveMessage("org.orcid.persistence.jpa.entities.CountryIsoEntity.US"));
    assertEquals(testCountry, countryNames);
    assertTrue(model.containsKey("publicGroupedKeywords"));
    Map<String, List<Keyword>> groupedKeywords = (Map<String, List<Keyword>>) model.get("publicGroupedKeywords");
    assertNotNull(groupedKeywords);
    assertEquals(1, groupedKeywords.keySet().size());
    assertTrue(groupedKeywords.containsKey("PUBLIC"));
    List<Keyword> publicKeywords = groupedKeywords.get("PUBLIC");
    assertEquals(1, publicKeywords.size());
    assertEquals(Long.valueOf(9), publicKeywords.get(0).getPutCode());
    assertEquals("PUBLIC", publicKeywords.get(0).getContent());
    assertEquals(Visibility.PUBLIC, publicKeywords.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedResearcherUrls"));
    Map<String, List<ResearcherUrl>> rUrls = (Map<String, List<ResearcherUrl>>) model.get("publicGroupedResearcherUrls");
    assertNotNull(rUrls);
    assertEquals(1, rUrls.keySet().size());
    assertTrue(rUrls.containsKey("http://www.researcherurl.com?id=13"));
    List<ResearcherUrl> publicResearchUrls = rUrls.get("http://www.researcherurl.com?id=13");
    assertEquals(Long.valueOf(13), publicResearchUrls.get(0).getPutCode());
    assertEquals("public_rurl", publicResearchUrls.get(0).getUrlName());
    assertEquals(Visibility.PUBLIC, publicResearchUrls.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedEmails"));
    Map<String, List<Email>> emails = (Map<String, List<Email>>) model.get("publicGroupedEmails");
    assertNotNull(emails);
    assertEquals(1, emails.keySet().size());
    assertTrue(emails.containsKey("public_0000-0000-0000-0003@test.orcid.org"));
    List<Email> publicEmails = emails.get("public_0000-0000-0000-0003@test.orcid.org");
    assertEquals("public_0000-0000-0000-0003@test.orcid.org", publicEmails.get(0).getEmail());
    assertEquals(Visibility.PUBLIC, publicEmails.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedPersonExternalIdentifiers"));
    Map<String, List<PersonExternalIdentifier>> extIds = (Map<String, List<PersonExternalIdentifier>>) model.get("publicGroupedPersonExternalIdentifiers");
    assertNotNull(extIds);
    assertEquals(1, extIds.keySet().size());
    assertTrue(extIds.containsKey("public_type:public_ref"));
    List<PersonExternalIdentifier> publicExternalIdentifiers = extIds.get("public_type:public_ref");
    assertEquals(Long.valueOf(13), publicExternalIdentifiers.get(0).getPutCode());
    assertEquals("http://ext-id/public_ref", publicExternalIdentifiers.get(0).getUrl().getValue());
    assertEquals(Visibility.PUBLIC, publicExternalIdentifiers.get(0).getVisibility());
    assertTrue(model.containsKey("affiliationIdsJson"));
    assertEquals("[17,47,42,37,32,27,20]", model.get("affiliationIdsJson"));
    assertTrue(model.containsKey("fundingIdsJson"));
    assertEquals("[10]", model.get("fundingIdsJson"));
    assertTrue(model.containsKey("peerReviewIdsJson"));
    assertEquals("[9]", model.get("peerReviewIdsJson"));
    assertTrue(model.containsKey("isProfileEmpty"));
    Boolean isProfileEmpty = (Boolean) model.get("isProfileEmpty");
    assertFalse(isProfileEmpty);
    assertFalse(model.containsKey("noIndex"));
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) HashMap(java.util.HashMap) Map(java.util.Map) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 78 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title in project ORCID-Source by ORCID.

the class PublicProfileControllerTest method testViewClaimedUserWhenIsLongEnough.

@Test
public void testViewClaimedUserWhenIsLongEnough() {
    // Update the submission date so it is long enough
    ProfileEntity profileEntity = profileDao.find(unclaimedUserOrcid);
    profileEntity.setSubmissionDate(DateUtils.addDays(new Date(), -10));
    profileDao.merge(profileEntity);
    profileDao.flush();
    ModelAndView mav = publicProfileController.publicPreview(request, response, 1, 0, 15, unclaimedUserOrcid);
    assertEquals("public_profile_v3", mav.getViewName());
    Map<String, Object> model = mav.getModel();
    assertNotNull(model);
    assertTrue(model.containsKey("isPublicProfile"));
    assertTrue(model.containsKey("effectiveUserOrcid"));
    assertEquals(unclaimedUserOrcid, model.get("effectiveUserOrcid"));
    assertTrue(!model.containsKey("biography"));
    assertFalse(model.containsKey("displayName"));
    assertFalse(model.containsKey("title"));
    assertTrue(model.containsKey("publicGroupedOtherNames"));
    Map<String, List<OtherName>> groupedOtherNames = (Map<String, List<OtherName>>) model.get("publicGroupedOtherNames");
    assertNotNull(groupedOtherNames);
    assertEquals(1, groupedOtherNames.keySet().size());
    List<OtherName> publicOtherNames = groupedOtherNames.get("PUBLIC");
    assertEquals(1, publicOtherNames.size());
    assertEquals(Long.valueOf(18), publicOtherNames.get(0).getPutCode());
    assertEquals("PUBLIC", publicOtherNames.get(0).getContent());
    assertEquals(Visibility.PUBLIC, publicOtherNames.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedAddresses"));
    Map<String, List<Address>> groupedAddresses = (Map<String, List<Address>>) model.get("publicGroupedAddresses");
    assertNotNull(groupedAddresses);
    assertEquals(1, groupedAddresses.keySet().size());
    assertTrue(groupedAddresses.containsKey("US"));
    List<Address> publicAddresses = groupedAddresses.get("US");
    assertEquals(1, publicAddresses.size());
    assertEquals(Long.valueOf(14), publicAddresses.get(0).getPutCode());
    assertEquals(Iso3166Country.US, publicAddresses.get(0).getCountry().getValue());
    assertEquals(Visibility.PUBLIC, publicAddresses.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedKeywords"));
    Map<String, List<Keyword>> groupedKeywords = (Map<String, List<Keyword>>) model.get("publicGroupedKeywords");
    assertNotNull(groupedKeywords);
    assertEquals(1, groupedKeywords.keySet().size());
    List<Keyword> publicKeywords = groupedKeywords.get("PUBLIC");
    assertEquals(Long.valueOf(14), publicKeywords.get(0).getPutCode());
    assertEquals("PUBLIC", publicKeywords.get(0).getContent());
    assertEquals(Visibility.PUBLIC, publicKeywords.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedResearcherUrls"));
    Map<String, List<ResearcherUrl>> rUrls = (Map<String, List<ResearcherUrl>>) model.get("publicGroupedResearcherUrls");
    assertNotNull(rUrls);
    assertEquals(1, rUrls.keySet().size());
    assertTrue(rUrls.containsKey("http://www.researcherurl.com?id=18"));
    List<ResearcherUrl> publicResearchUrls = rUrls.get("http://www.researcherurl.com?id=18");
    assertEquals(Long.valueOf(18), publicResearchUrls.get(0).getPutCode());
    assertEquals("public", publicResearchUrls.get(0).getUrlName());
    assertEquals(Visibility.PUBLIC, publicResearchUrls.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedEmails"));
    Map<String, List<Email>> emails = (Map<String, List<Email>>) model.get("publicGroupedEmails");
    assertNotNull(emails);
    assertEquals(1, emails.keySet().size());
    List<Email> groupedEmails = emails.get("public_0000-0000-0000-0001@test.orcid.org");
    assertEquals("public_0000-0000-0000-0001@test.orcid.org", groupedEmails.get(0).getEmail());
    assertEquals(Visibility.PUBLIC, groupedEmails.get(0).getVisibility());
    assertTrue(model.containsKey("publicGroupedPersonExternalIdentifiers"));
    Map<String, List<PersonExternalIdentifier>> extIds = (Map<String, List<PersonExternalIdentifier>>) model.get("publicGroupedPersonExternalIdentifiers");
    assertNotNull(extIds);
    assertEquals(1, extIds.keySet().size());
    assertTrue(extIds.containsKey("public:public"));
    List<PersonExternalIdentifier> publicExternalIdentifiers = extIds.get("public:public");
    assertEquals(Long.valueOf(18), publicExternalIdentifiers.get(0).getPutCode());
    assertEquals("http://ext-id/self/public", publicExternalIdentifiers.get(0).getUrl().getValue());
    assertEquals(Visibility.PUBLIC, publicExternalIdentifiers.get(0).getVisibility());
    assertTrue(model.containsKey("isProfileEmpty"));
    Boolean isProfileEmpty = (Boolean) model.get("isProfileEmpty");
    assertTrue(isProfileEmpty);
    assertFalse(model.containsKey("noIndex"));
    // Update the submission date so it is not long enough
    profileEntity = profileDao.find(unclaimedUserOrcid);
    profileEntity.setSubmissionDate(new Date());
    profileDao.merge(profileEntity);
    profileDao.flush();
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(java.util.Date) HashMap(java.util.HashMap) Map(java.util.Map) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 79 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title in project ORCID-Source by ORCID.

the class WorksPaginatorTest method getTitle.

private WorkTitle getTitle(int i) {
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(UUID.randomUUID().toString()));
    title.setSubtitle(new Subtitle(UUID.randomUUID().toString()));
    return title;
}
Also used : Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle)

Example 80 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)81 Title (org.orcid.jaxb.model.v3.dev1.common.Title)44 Work (org.orcid.jaxb.model.v3.dev1.record.Work)43 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)40 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)38 Url (org.orcid.jaxb.model.v3.dev1.common.Url)33 DBUnitTest (org.orcid.test.DBUnitTest)29 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)27 ClientResponse (com.sun.jersey.api.client.ClientResponse)26 Response (javax.ws.rs.core.Response)25 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)23 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)19 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)17 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)17 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)14 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)14 ArrayList (java.util.ArrayList)13 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)13 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)13 Visibility (org.orcid.jaxb.model.v3.dev1.common.Visibility)13