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());
}
Aggregations