Search in sources :

Example 51 with OrcidMessage

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

the class PublicV1Test method testGetInfoWithEmptyToken.

@Test
public void testGetInfoWithEmptyToken() throws InterruptedException, JSONException {
    ClientResponse response = publicV1ApiClient.viewRootProfile(getUser1OrcidId(), "");
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    OrcidMessage message = response.getEntity(OrcidMessage.class);
    assertNotNull(message);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 52 with OrcidMessage

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

the class PublicV1Test method testViewPublicProfileUsingToken.

@Test
public void testViewPublicProfileUsingToken() throws JSONException, InterruptedException {
    String accessToken = getAccessToken();
    ClientResponse response = publicV1ApiClient.viewRootProfile(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    OrcidMessage message = response.getEntity(OrcidMessage.class);
    assertNotNull(message);
    assertNotNull(message.getOrcidProfile());
    assertNotNull(message.getOrcidProfile().getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), message.getOrcidProfile().getOrcidIdentifier().getPath());
    response = publicV1ApiClient.viewPublicProfile(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    message = response.getEntity(OrcidMessage.class);
    assertNotNull(message);
    assertNotNull(message.getOrcidProfile());
    assertNotNull(message.getOrcidProfile().getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), message.getOrcidProfile().getOrcidIdentifier().getPath());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 53 with OrcidMessage

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

the class PublicV1Test method testPublicSearchAnonymously.

@Test
public void testPublicSearchAnonymously() {
    ClientResponse response = publicV1ApiClient.doPublicSearch(getUser1OrcidId());
    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 54 with OrcidMessage

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

the class S3UpdaterTest method updateS3_OrcidProfileTest.

@Test
public void updateS3_OrcidProfileTest() throws JAXBException, JsonProcessingException, AmazonClientException {
    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.anyString());
    verify(s3MessagingService, times(1)).send(Matchers.eq(bucketPrefix + "-api-1-2-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.anyString());
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-2-0-json-x"), Matchers.eq(orcid + ".xml"), Matchers.anyString());
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-2-0-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.anyString());
}
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 55 with OrcidMessage

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

the class LastModifiedMessageProcessorTest method recrodStatusMarkAsSentForLockedRecordException20Test.

@Test
public void recrodStatusMarkAsSentForLockedRecordException20Test() throws LockedRecordException, DeprecatedRecordException {
    when(mock_orcid12ApiClient.fetchPublicProfile(Matchers.anyString())).thenReturn(null);
    when(mock_orcid20ApiClient.fetchPublicProfile(Matchers.anyString())).thenThrow(new LockedRecordException(new OrcidMessage()));
    String orcid = "0000-0000-0000-0000";
    execute(orcid);
    verify(mock_recordStatusManager, times(0)).markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
    verify(mock_recordStatusManager, times(0)).markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
    verify(mock_recordStatusManager, times(1)).markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
    verify(mock_recordStatusManager, times(0)).markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
}
Also used : LockedRecordException(org.orcid.listener.exception.LockedRecordException) 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