Search in sources :

Example 46 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ExternalIdentifierManagerTest method getAllTest.

@Test
public void getAllTest() {
    String orcid = "0000-0000-0000-0003";
    PersonExternalIdentifiers elements = externalIdentifierManager.getExternalIdentifiers(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertNotNull(elements.getExternalIdentifiers());
    assertEquals(5, elements.getExternalIdentifiers().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (PersonExternalIdentifier element : elements.getExternalIdentifiers()) {
        if (13 == element.getPutCode()) {
            found1 = true;
        } else if (14 == element.getPutCode()) {
            found2 = true;
        } else if (15 == element.getPutCode()) {
            found3 = true;
        } else if (16 == element.getPutCode()) {
            found4 = true;
        } else if (17 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid put code found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 47 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testUnmarshallExternalIdentifiers.

@Test
public void testUnmarshallExternalIdentifiers() throws SAXException, URISyntaxException {
    PersonExternalIdentifiers externalIdentifiers = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.0_rc2/samples/external-identifiers-2.0_rc2.xml", PersonExternalIdentifiers.class, "/record_2.0_rc2/person-external-identifier-2.0_rc2.xsd");
    assertNotNull(externalIdentifiers);
    assertNotNull(externalIdentifiers.getExternalIdentifiers());
    assertEquals(2, externalIdentifiers.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : externalIdentifiers.getExternalIdentifiers()) {
        assertThat(extId.getPutCode(), anyOf(is(1L), is(2L)));
        assertThat(extId.getType(), anyOf(is("common-name-1"), is("common-name-2")));
        assertThat(extId.getValue(), anyOf(is("id-reference-1"), is("id-reference-2")));
        assertNotNull(extId.getUrl());
        assertThat(extId.getUrl().getValue(), anyOf(is("http://url/1"), is("http://url/2")));
        assertNotNull(extId.getCreatedDate());
        assertNotNull(extId.getLastModifiedDate());
        assertNotNull(extId.getSource());
        assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
    }
    PersonExternalIdentifier extId = (PersonExternalIdentifier) unmarshallFromPath("/record_2.0_rc2/samples/external-identifier-2.0_rc2.xml", PersonExternalIdentifier.class);
    assertNotNull(extId);
    assertEquals("A-0003", extId.getType());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("A-0003", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://ext-id/A-0003", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) Test(org.junit.Test)

Example 48 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testMarshallExternalIdentifiers.

@Test
public void testMarshallExternalIdentifiers() throws JAXBException, SAXException, URISyntaxException {
    PersonExternalIdentifiers object = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.0_rc2/samples/external-identifiers-2.0_rc2.xml", PersonExternalIdentifiers.class);
    marshall(object, "/record_2.0_rc2/person-external-identifier-2.0_rc2.xsd");
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers) Test(org.junit.Test)

Example 49 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testDeleteExternalIdentifier.

@Test
public void testDeleteExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4444");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(1, extIds.getExternalIdentifiers().size());
    assertEquals(Long.valueOf(6), extIds.getExternalIdentifiers().get(0).getPutCode());
    response = serviceDelegator.deleteExternalIdentifier("4444-4444-4444-4444", 6L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4444");
    assertNotNull(response);
    extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertTrue(extIds.getExternalIdentifiers().isEmpty());
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 50 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testAddExternalIdentifier.

@Test
public void testAddExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4443");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(1, extIds.getExternalIdentifiers().size());
    assertEquals(Long.valueOf(1), extIds.getExternalIdentifiers().get(0).getPutCode());
    assertNotNull(extIds.getExternalIdentifiers().get(0).getUrl());
    assertEquals("http://www.facebook.com/d3clan", extIds.getExternalIdentifiers().get(0).getUrl().getValue());
    assertEquals("d3clan", extIds.getExternalIdentifiers().get(0).getValue());
    assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
    response = serviceDelegator.createExternalIdentifier("4444-4444-4444-4443", Utils.getPersonExternalIdentifier());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4443");
    assertNotNull(response);
    extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(2, extIds.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
        Utils.verifyLastModified(extId.getLastModifiedDate());
        assertNotNull(extId.getUrl());
        if (extId.getPutCode() != 1L) {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("new-common-name", extId.getType());
            assertEquals("new-reference", extId.getValue());
            assertEquals("http://newUrl.com", extId.getUrl().getValue());
            assertEquals(putCode, extId.getPutCode());
        } else {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("Facebook", extId.getType());
            assertEquals("d3clan", extId.getValue());
            assertEquals("http://www.facebook.com/d3clan", extId.getUrl().getValue());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) List(java.util.List) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)54 Test (org.junit.Test)52 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)47 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)37 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Biography (org.orcid.jaxb.model.record_v2.Biography)35 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 Address (org.orcid.jaxb.model.record_v2.Address)34 Email (org.orcid.jaxb.model.record_v2.Email)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Keyword (org.orcid.jaxb.model.record_v2.Keyword)33 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)33 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Name (org.orcid.jaxb.model.record_v2.Name)28 Person (org.orcid.jaxb.model.record_v2.Person)25 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)15