Search in sources :

Example 46 with OrcidMessage

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

the class MemberV1Test method unmarshallFromPath.

public OrcidMessage unmarshallFromPath(String path) throws Exception {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        JAXBContext context = JAXBContext.newInstance(OrcidProfile.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return (OrcidMessage) unmarshaller.unmarshal(reader);
    } catch (Exception e) {
        throw new RuntimeException("Error reading file from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 47 with OrcidMessage

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

the class LockUnlockRecordTest method checkIfLockedPub.

public boolean checkIfLockedPub() {
    ClientResponse response = t1OAuthClient.viewFullDetailsXml(getUser1OrcidId());
    assertNotNull(response);
    OrcidMessage message = response.getEntity(OrcidMessage.class);
    if (message.getOrcidProfile() == null && message.getErrorDesc() != null) {
        assertEquals("Account locked : The given account " + getUser1OrcidId() + " is locked", message.getErrorDesc().getContent());
        return true;
    }
    return false;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 48 with OrcidMessage

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

the class LockUnlockRecordTest method checkIfLockedApi.

public boolean checkIfLockedApi() {
    ClientResponse response = t2OAuthClient_1_2.viewFullDetailsXml(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    OrcidMessage message = response.getEntity(OrcidMessage.class);
    if (message.getOrcidProfile() == null && message.getErrorDesc() != null) {
        assertEquals("Account locked : The given account " + getUser1OrcidId() + " is locked", message.getErrorDesc().getContent());
        return true;
    }
    return false;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 49 with OrcidMessage

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

the class PublicV1Test method testPublicSearchUsingToken.

@Test
public void testPublicSearchUsingToken() throws InterruptedException, JSONException {
    String accessToken = getAccessToken();
    ClientResponse response = publicV1ApiClient.doPublicSearch(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    OrcidMessage orcidMessage = response.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessage);
    assertNotNull(orcidMessage.getOrcidSearchResults());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0));
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile().getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile().getOrcidIdentifier().getPath());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 50 with OrcidMessage

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

the class PublicV1Test method testPublicSearchUsingPublicClient.

@Test
public void testPublicSearchUsingPublicClient() throws InterruptedException, JSONException {
    String accessToken = oauthHelper.getClientCredentialsAccessToken(getPublicClientId(), getPublicClientSecret(), ScopePathType.READ_PUBLIC, APIRequestType.PUBLIC);
    ClientResponse response = publicV1ApiClient.doPublicSearch(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    OrcidMessage orcidMessage = response.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessage);
    assertNotNull(orcidMessage.getOrcidSearchResults());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0));
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile());
    assertNotNull(orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile().getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), orcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0).getOrcidProfile().getOrcidIdentifier().getPath());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Aggregations

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)173 Test (org.junit.Test)108 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)64 DBUnitTest (org.orcid.test.DBUnitTest)49 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 Response (javax.ws.rs.core.Response)26 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)22 Transactional (org.springframework.transaction.annotation.Transactional)22 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)20 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)19 Email (org.orcid.jaxb.model.message.Email)18 BaseTest (org.orcid.core.BaseTest)17 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)16 Affiliation (org.orcid.jaxb.model.message.Affiliation)13 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)12 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)12 JAXBContext (javax.xml.bind.JAXBContext)11 Unmarshaller (javax.xml.bind.Unmarshaller)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11