Search in sources :

Example 26 with ContactDetails

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

the class EmailsTest method updateEmailsUsingAlreadyExistingEmailTest.

/**
 * Test update email using already existing email
 */
@Test
public void updateEmailsUsingAlreadyExistingEmailTest() throws JSONException, InterruptedException {
    String clientId = getClient1ClientId();
    String clientRedirectUri = getClient1RedirectUri();
    String clientSecret = getClient1ClientSecret();
    String userId = getUser1OrcidId();
    String password = getUser1Password();
    String user2Email = getUser2UserName();
    String accessToken = getAccessToken(userId, password, Arrays.asList("/orcid-bio/update"), clientId, clientSecret, clientRedirectUri, true);
    // Email already used by 9999-9999-9999-9990
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.getEmail().add(new Email(user2Email));
    OrcidBio orcidBio = new OrcidBio();
    orcidBio.setContactDetails(contactDetails);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setType(OrcidType.USER);
    orcidProfile.setOrcidBio(orcidBio);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    orcidMessage.setOrcidProfile(orcidProfile);
    ClientResponse clientResponse = t2OAuthClient_1_2.updateBioDetailsXml(userId, orcidMessage, accessToken);
    assertEquals(400, clientResponse.getStatus());
    OrcidMessage errorMessage = clientResponse.getEntity(OrcidMessage.class);
    assertNotNull(errorMessage);
    assertNotNull(errorMessage.getErrorDesc());
    assertEquals("Bad Request: Invalid incoming message: Email " + user2Email + " belongs to other user", errorMessage.getErrorDesc().getContent());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.message.Email) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Aggregations

ContactDetails (org.orcid.jaxb.model.message.ContactDetails)26 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)23 Email (org.orcid.jaxb.model.message.Email)22 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)18 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)17 GivenNames (org.orcid.jaxb.model.message.GivenNames)13 FamilyName (org.orcid.jaxb.model.message.FamilyName)12 CreditName (org.orcid.jaxb.model.message.CreditName)8 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)8 ArrayList (java.util.ArrayList)7 Biography (org.orcid.jaxb.model.message.Biography)7 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)7 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)6 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)6 Date (java.util.Date)5 Keyword (org.orcid.jaxb.model.message.Keyword)5 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)5 OtherName (org.orcid.jaxb.model.message.OtherName)5