Search in sources :

Example 41 with ResearcherUrl

use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrlReadPublic.

@Test
public void testViewResearcherUrlReadPublic() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    ResearcherUrl element = (ResearcherUrl) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/researcher-urls/13", element.getPath());
    Utils.assertIsPublicOrSource(element, SecurityContextTestUtils.DEFAULT_CLIENT_ID);
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 42 with ResearcherUrl

use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewPrivateResearcherUrl.

@Test
public void testViewPrivateResearcherUrl() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 7L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    assertEquals("/4444-4444-4444-4443/researcher-urls/7", researcherUrl.getPath());
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    assertEquals("APP-5555555555555555", researcherUrl.getSource().retrieveSourcePath());
    assertEquals("http://www.researcherurl2.com?id=7", researcherUrl.getUrl().getValue());
    assertEquals("443_5", researcherUrl.getUrlName());
    assertEquals(Visibility.PRIVATE, researcherUrl.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 43 with ResearcherUrl

use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrls.

@Test
public void testViewResearcherUrls() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewResearcherUrls("4444-4444-4444-4443");
    assertNotNull(response);
    ResearcherUrls researcherUrls = (ResearcherUrls) response.getEntity();
    assertNotNull(researcherUrls);
    Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
    assertEquals("/4444-4444-4444-4443/researcher-urls", researcherUrls.getPath());
    assertNotNull(researcherUrls.getResearcherUrls());
    assertEquals(5, researcherUrls.getResearcherUrls().size());
    for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) {
        assertThat(rUrl.getPutCode(), anyOf(equalTo(Long.valueOf(2)), equalTo(Long.valueOf(3)), equalTo(Long.valueOf(5)), equalTo(Long.valueOf(7)), equalTo(Long.valueOf(8))));
        Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
        assertNotNull(rUrl.getSource());
        assertFalse(PojoUtil.isEmpty(rUrl.getSource().retrieveSourcePath()));
        assertNotNull(rUrl.getUrl());
        assertNotNull(rUrl.getUrlName());
        assertNotNull(rUrl.getVisibility());
        if (rUrl.getPutCode().equals(Long.valueOf(5)) || rUrl.getPutCode().equals(Long.valueOf(7))) {
            assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 44 with ResearcherUrl

use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testAddResearcherUrl.

@Test
public void testAddResearcherUrl() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.createResearcherUrl("4444-4444-4444-4441", Utils.getResearcherUrl());
    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.viewResearcherUrl("4444-4444-4444-4441", putCode);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    assertEquals("APP-5555555555555555", researcherUrl.getSource().retrieveSourcePath());
    assertEquals("http://www.myRUrl.com", researcherUrl.getUrl().getValue());
    assertEquals("My researcher Url", researcherUrl.getUrlName());
    assertEquals(Visibility.PUBLIC, researcherUrl.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 45 with ResearcherUrl

use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testUpdateResearcherUrlYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateResearcherUrlYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 8L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://www.researcherurl2.com?id=8", researcherUrl.getUrl().getValue());
    assertEquals("443_6", researcherUrl.getUrlName());
    researcherUrl.setUrlName("Updated Name");
    serviceDelegator.updateResearcherUrl("4444-4444-4444-4443", 8L, researcherUrl);
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)77 Test (org.junit.Test)55 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)41 Address (org.orcid.jaxb.model.v3.dev1.record.Address)39 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)39 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)38 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)38 Email (org.orcid.jaxb.model.v3.dev1.record.Email)36 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)31 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)31 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)30 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)30 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)30 Person (org.orcid.jaxb.model.v3.dev1.record.Person)28 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15