Search in sources :

Example 76 with Keyword

use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_KeywordsTest method testAddKeyword.

@Test
public void testAddKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.createKeyword("4444-4444-4444-4441", Utils.getKeyword());
    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.viewKeyword("4444-4444-4444-4441", putCode);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    Keyword newKeyword = (Keyword) response.getEntity();
    assertNotNull(newKeyword);
    Utils.verifyLastModified(newKeyword.getLastModifiedDate());
    assertEquals("New keyword", newKeyword.getContent());
    assertEquals(Visibility.PUBLIC, newKeyword.getVisibility());
    assertNotNull(newKeyword.getSource());
    assertEquals("APP-5555555555555555", newKeyword.getSource().retrieveSourcePath());
    assertNotNull(newKeyword.getCreatedDate());
    Utils.verifyLastModified(newKeyword.getLastModifiedDate());
}
Also used : Response(javax.ws.rs.core.Response) Keyword(org.orcid.jaxb.model.record_v2.Keyword) List(java.util.List) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 77 with Keyword

use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_KeywordsTest method testViewPrivateKeyword.

@Test
public void testViewPrivateKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4443", 4L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    assertEquals("/4444-4444-4444-4443/keywords/4", keyword.getPath());
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    assertEquals("what else can we make?", keyword.getContent());
    assertEquals(Visibility.PRIVATE, keyword.getVisibility());
    assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 78 with Keyword

use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_KeywordsTest method testViewKeywordReadPublic.

@Test
public void testViewKeywordReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewKeyword(ORCID, 9L);
    Keyword element = (Keyword) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/keywords/9", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 79 with Keyword

use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeywordChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateKeywordChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    keyword.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 80 with Keyword

use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeyword.

@Test
public void testUpdateKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    LastModifiedDate before = keyword.getLastModifiedDate();
    assertEquals("keyword-2", keyword.getContent());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    keyword.setContent("Updated keyword");
    response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
    assertNotNull(response);
    keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    assertTrue(keyword.getLastModifiedDate().after(before));
    assertEquals("Updated keyword", keyword.getContent());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)88 Keyword (org.orcid.jaxb.model.record_v2.Keyword)82 Address (org.orcid.jaxb.model.record_v2.Address)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Keywords (org.orcid.jaxb.model.record_v2.Keywords)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 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 DBUnitTest (org.orcid.test.DBUnitTest)20 Keyword (org.orcid.jaxb.model.record_rc3.Keyword)19 Response (javax.ws.rs.core.Response)18