use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class Api12PublicTest method testViewFullDetailsJson.
@Test
public void testViewFullDetailsJson() throws Exception {
ClientResponse clientResponse = t1OAuthClient.viewFullDetailsJson(getUser1OrcidId());
assertNotNull(clientResponse);
assertEquals(200, clientResponse.getStatus());
OrcidMessage orcidMessage = clientResponse.getEntity(OrcidMessage.class);
assertNotNull(orcidMessage);
assertEquals(getUser1OrcidId(), orcidMessage.getOrcidProfile().getOrcidIdentifier().getPath());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class AccessTokenSecurityChecksTest method evaluateResponseOn12API.
private void evaluateResponseOn12API(ClientResponse response) {
assertNotNull(response);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), response.getStatus());
OrcidMessage orcidMessage = response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessage);
assertNotNull(orcidMessage.getErrorDesc());
assertEquals("Security problem : You do not have the required permissions.", orcidMessage.getErrorDesc().getContent());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class EmailsTest method cantUpdateEmailsTest.
/**
* Test update email for a specific user
* */
@Test
public void cantUpdateEmailsTest() throws JSONException, InterruptedException {
String clientId = getClient1ClientId();
String clientRedirectUri = getClient1RedirectUri();
String clientSecret = getClient1ClientSecret();
String userId = getUser1OrcidId();
String originalEmail = getUser1UserName();
String password = getUser1Password();
String accessToken = getAccessToken(userId, password, Arrays.asList("/orcid-bio/update"), clientId, clientSecret, clientRedirectUri, true);
long time = System.currentTimeMillis();
String updatedEmail = time + "@update.com";
ContactDetails contactDetails = new ContactDetails();
contactDetails.getEmail().add(new Email(updatedEmail));
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(200, clientResponse.getStatus());
clientResponse = t2OAuthClient_1_2.viewBioDetailsXml(userId, accessToken);
assertEquals(200, clientResponse.getStatus());
OrcidMessage result = clientResponse.getEntity(OrcidMessage.class);
// Check returning message
assertNotNull(result);
assertNotNull(result.getOrcidProfile());
assertNotNull(result.getOrcidProfile().getOrcidBio());
assertNotNull(result.getOrcidProfile().getOrcidBio().getContactDetails());
assertNotNull(result.getOrcidProfile().getOrcidBio().getContactDetails().getEmail());
boolean haveOriginalEmail = false;
for (Email email : result.getOrcidProfile().getOrcidBio().getContactDetails().getEmail()) {
assertFalse(email.getValue().equals(updatedEmail));
if (email.getValue().equals(originalEmail)) {
haveOriginalEmail = true;
}
}
assertTrue(haveOriginalEmail);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class Api12Helper method addFunding.
protected static void addFunding(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
FundingList fundings = new FundingList();
Funding funding = new Funding();
funding.setVisibility(Visibility.LIMITED);
FundingTitle fundingTitle = new FundingTitle();
fundingTitle.setTitle(new Title(title));
funding.setTitle(fundingTitle);
funding.setType(FundingType.SALARY_AWARD);
Amount amount = new Amount();
amount.setCurrencyCode("CRC");
amount.setContent("1,250,000");
funding.setAmount(amount);
funding.setStartDate(new FuzzyDate(2010, 1, 1));
funding.setEndDate(new FuzzyDate(2013, 1, 1));
funding.setDescription("My Grant description");
funding.setUrl(new Url("http://url.com"));
Organization org = new Organization();
org.setName("Orcid Integration Test Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.CR);
org.setAddress(add);
funding.setOrganization(org);
FundingExternalIdentifier extIdentifier = new FundingExternalIdentifier();
extIdentifier.setType(FundingExternalIdentifierType.fromValue("grant_number"));
extIdentifier.setUrl(new Url("http://url.com"));
extIdentifier.setValue("My value");
FundingExternalIdentifiers extIdentifiers = new FundingExternalIdentifiers();
extIdentifiers.getFundingExternalIdentifier().add(extIdentifier);
funding.setFundingExternalIdentifiers(extIdentifiers);
FundingContributors contributors = new FundingContributors();
FundingContributor contributor = new FundingContributor();
contributor.setCreditName(new CreditName("My Credit Name"));
contributor.setContributorEmail(new ContributorEmail("my.email@orcid-integration-test.com"));
FundingContributorAttributes attributes = new FundingContributorAttributes();
attributes.setContributorRole(FundingContributorRole.LEAD);
contributor.setContributorAttributes(attributes);
contributors.getContributor().add(contributor);
funding.setFundingContributors(contributors);
fundings.getFundings().add(funding);
orcidMessage.getOrcidProfile().getOrcidActivities().setFundings(fundings);
ClientResponse clientResponse = oauthT2Client.addFundingXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class Api12Helper method addWork.
protected static void addWork(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
String id = String.valueOf(System.currentTimeMillis());
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setWorkType(WorkType.JOURNAL_ARTICLE);
orcidWork.setVisibility(Visibility.LIMITED);
WorkTitle workTitle = new WorkTitle();
orcidWork.setWorkTitle(workTitle);
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId(id));
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
extIds.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(extIds);
workTitle.setTitle(new Title(title));
ClientResponse clientResponse = oauthT2Client.addWorksXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
Aggregations