Search in sources :

Example 31 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testUpdateResearcherUrl.

@Test
public void testUpdateResearcherUrl() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    LastModifiedDate before = researcherUrl.getLastModifiedDate();
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://www.researcherurl2.com?id=5", researcherUrl.getUrl().getValue());
    assertEquals("443_3", researcherUrl.getUrlName());
    researcherUrl.setUrl(new Url("http://theNewResearcherUrl.com"));
    researcherUrl.setUrlName("My Updated Researcher Url");
    response = serviceDelegator.updateResearcherUrl("4444-4444-4444-4443", 5L, researcherUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    assertTrue(researcherUrl.getLastModifiedDate().after(before));
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://theNewResearcherUrl.com", researcherUrl.getUrl().getValue());
    assertEquals("My Updated Researcher Url", researcherUrl.getUrlName());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testViewLimitedResearcherUrl.

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

Example 33 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testUpdateResearcherUrlLeavingVisibilityNullTest.

@Test
public void testUpdateResearcherUrlLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertEquals(Visibility.LIMITED, researcherUrl.getVisibility());
    researcherUrl.setVisibility(null);
    response = serviceDelegator.updateResearcherUrl("4444-4444-4444-4443", 5L, researcherUrl);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    researcherUrl = (ResearcherUrl) response.getEntity();
    assertEquals(Visibility.LIMITED, researcherUrl.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 35 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)86 Test (org.junit.Test)76 OtherName (org.orcid.jaxb.model.record_v2.OtherName)45 Address (org.orcid.jaxb.model.record_v2.Address)44 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)43 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18