Search in sources :

Example 86 with Keyword

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

the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeywordYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateKeywordYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4443", 2L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    assertEquals("coffee making", keyword.getContent());
    assertEquals(Visibility.LIMITED, keyword.getVisibility());
    assertNotNull(keyword.getSource());
    assertEquals("4444-4444-4444-4443", keyword.getSource().retrieveSourcePath());
    keyword.setContent("Updated Keyword " + System.currentTimeMillis());
    serviceDelegator.updateKeyword("4444-4444-4444-4443", 2L, 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 87 with Keyword

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

the class MemberV2ApiServiceDelegator_KeywordsTest method testViewLimitedKeyword.

@Test
public void testViewLimitedKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4443", 2L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    assertEquals("/4444-4444-4444-4443/keywords/2", keyword.getPath());
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    assertEquals("coffee making", keyword.getContent());
    assertEquals(Visibility.LIMITED, keyword.getVisibility());
    assertEquals("4444-4444-4444-4443", 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 88 with Keyword

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

the class MemberV2ApiServiceDelegator_KeywordsTest method testViewPublicKeyword.

@Test
public void testViewPublicKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    assertEquals("/4444-4444-4444-4443/keywords/1", keyword.getPath());
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    assertEquals("tea making", keyword.getContent());
    assertEquals(Visibility.PUBLIC, 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 89 with Keyword

use of org.orcid.jaxb.model.record_v2.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 90 with Keyword

use of org.orcid.jaxb.model.record_v2.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)

Aggregations

Test (org.junit.Test)89 Keyword (org.orcid.jaxb.model.record_v2.Keyword)82 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)47 OtherName (org.orcid.jaxb.model.record_v2.OtherName)46 Address (org.orcid.jaxb.model.record_v2.Address)45 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)45 Keywords (org.orcid.jaxb.model.record_v2.Keywords)44 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)35 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Name (org.orcid.jaxb.model.record_v2.Name)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Person (org.orcid.jaxb.model.record_v2.Person)30 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 DBUnitTest (org.orcid.test.DBUnitTest)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)19 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)19