Search in sources :

Example 86 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class SourceInActivitiesTest method before.

@Before
public void before() {
    TargetProxyHelper.injectIntoProxy(workManager, "sourceManager", mockSourceManager);
    TargetProxyHelper.injectIntoProxy(profileFundingManager, "sourceManager", mockSourceManager);
    TargetProxyHelper.injectIntoProxy(affiliationsManager, "sourceManager", mockSourceManager);
    TargetProxyHelper.injectIntoProxy(peerReviewManager, "sourceManager", mockSourceManager);
    TargetProxyHelper.injectIntoProxy(orcidProfileManager, "sourceManager", mockSourceManager);
    if (PojoUtil.isEmpty(userOrcid)) {
        when(mockSourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
        OrcidProfile newUser = getMinimalOrcidProfile();
        userOrcid = newUser.getOrcidIdentifier().getPath();
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Before(org.junit.Before)

Example 87 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class JpaJaxbEntityAdapterToOrcidProfileTest method testToOrcidProfileWithNewWayOfDoingEmails.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testToOrcidProfileWithNewWayOfDoingEmails() throws SAXException, IOException {
    ProfileEntity profileEntity = profileDao.find("4444-4444-4444-4445");
    long start = System.currentTimeMillis();
    OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity, LoadOptions.ALL);
    System.out.println("Took: " + Long.toString(System.currentTimeMillis() - start));
    ContactDetails contactDetails = orcidProfile.getOrcidBio().getContactDetails();
    Email primaryEmail = contactDetails.retrievePrimaryEmail();
    assertNotNull(primaryEmail);
    assertTrue(primaryEmail.isPrimary());
    assertTrue(primaryEmail.isCurrent());
    assertFalse(primaryEmail.isVerified());
    assertEquals(Visibility.PRIVATE, primaryEmail.getVisibility());
    assertEquals("andrew@timothy.com", primaryEmail.getValue());
    assertEquals("4444-4444-4444-4441", primaryEmail.getSource());
    Email nonPrimaryEmail = contactDetails.getEmailByString("andrew2@timothy.com");
    assertNotNull(nonPrimaryEmail);
    assertFalse(nonPrimaryEmail.isPrimary());
    assertFalse(nonPrimaryEmail.isCurrent());
    assertFalse(nonPrimaryEmail.isVerified());
    assertEquals(Visibility.PRIVATE, nonPrimaryEmail.getVisibility());
    assertEquals("andrew2@timothy.com", nonPrimaryEmail.getValue());
    assertEquals("4444-4444-4444-4441", nonPrimaryEmail.getSource());
    assertEquals(2, contactDetails.getEmail().size());
    validateAgainstSchema(new OrcidMessage(orcidProfile));
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 88 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class JpaJaxbEntityAdapterToOrcidProfileTest method testToOrcidProfile.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testToOrcidProfile() throws SAXException, IOException {
    ProfileEntity profileEntity = profileDao.find("4444-4444-4444-4443");
    long start = System.currentTimeMillis();
    OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity, LoadOptions.ALL);
    System.out.println("Took: " + Long.toString(System.currentTimeMillis() - start));
    System.out.println(orcidProfile);
    checkOrcidProfile(orcidProfile);
    validateAgainstSchema(new OrcidMessage(orcidProfile));
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 89 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class S3UpdaterTest method updateS3_OrcidProfileTest.

@Test
public void updateS3_OrcidProfileTest() throws JAXBException, AmazonClientException, IOException {
    String bucketPrefix = "bucket-production";
    String orcid = "0000-0000-0000-000X";
    OrcidMessage om = new OrcidMessage();
    OrcidProfile op = new OrcidProfile();
    op.setOrcidIdentifier(orcid);
    om.setOrcidProfile(op);
    S3Updater s3 = new S3Updater(bucketPrefix);
    s3.setS3MessagingService(s3MessagingService);
    s3.updateS3(orcid, om);
    verify(s3MessagingService, times(1)).send(Matchers.eq(bucketPrefix + "-api-1-2-json-x"), Matchers.eq(orcid + ".json"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(1)).send(Matchers.eq(bucketPrefix + "-api-1-2-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-2-0-json-x"), Matchers.eq(orcid + ".xml"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-2-0-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.any(), Matchers.any());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) S3Updater(org.orcid.listener.s3.S3Updater) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 90 with OrcidProfile

use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.

the class RegistrationManagerImplTest method createBasicProfile.

private OrcidProfile createBasicProfile(String email, boolean claimed, String sourceId) {
    OrcidProfile profile = new OrcidProfile();
    profile.setPassword("password");
    profile.setVerificationCode("1234");
    OrcidBio bio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.addOrReplacePrimaryEmail(new Email(email));
    bio.setContactDetails(contactDetails);
    profile.setOrcidBio(bio);
    PersonalDetails personalDetails = new PersonalDetails();
    bio.setPersonalDetails(personalDetails);
    personalDetails.setGivenNames(new GivenNames("New"));
    personalDetails.setFamilyName(new FamilyName("User"));
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setClaimed(new Claimed(claimed));
    orcidHistory.setCreationMethod(CreationMethod.DIRECT);
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile.setOrcidHistory(orcidHistory);
    // Set the source
    profile.getOrcidHistory().setSource(new Source(sourceId));
    return profile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Source(org.orcid.jaxb.model.message.Source)

Aggregations

OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)241 Test (org.junit.Test)118 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)77 Transactional (org.springframework.transaction.annotation.Transactional)50 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)45 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)43 DBUnitTest (org.orcid.test.DBUnitTest)43 Rollback (org.springframework.test.annotation.Rollback)40 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)36 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)35 Date (java.util.Date)27 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)27 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)25 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)23 Affiliations (org.orcid.jaxb.model.message.Affiliations)22 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)22 Title (org.orcid.jaxb.model.message.Title)22 Email (org.orcid.jaxb.model.message.Email)21 GivenNames (org.orcid.jaxb.model.message.GivenNames)21 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)21