Search in sources :

Example 21 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testWork_CanRead_When_HaveReadScope_IsPublic_NotSource.

@Test
public void testWork_CanRead_When_HaveReadScope_IsPublic_NotSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_WORKS_READ_LIMITED);
    Work work = createWork(Visibility.PUBLIC, CLIENT_2);
    orcidSecurityManager.checkAndFilter(ORCID_1, work, ScopePathType.ORCID_WORKS_READ_LIMITED);
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 22 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class WorkManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Work w1 = getWork("fromUI-1");
    w1 = workManager.createWork(claimedOrcid, w1, false);
    WorkEntity w = workDao.find(w1.getPutCode());
    assertNotNull(w1);
    assertEquals(Long.valueOf(1), w.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 23 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class WorkManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Work w1 = getWork("fromAPI-1");
    w1 = workManager.createWork(claimedOrcid, w1, true);
    WorkEntity w = workDao.find(w1.getPutCode());
    assertNotNull(w1);
    assertEquals(Long.valueOf(0), w.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 24 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class BibtexManagerTest method testDOIManagerIsInvoked.

@Test
public void testDOIManagerIsInvoked() {
    when(doiManager.fetchDOIBibtex("111")).thenReturn("OK");
    Work w = new Work();
    w.setWorkExternalIdentifiers(new ExternalIDs());
    ExternalID id = new ExternalID();
    id.setType("doi");
    id.setValue("111");
    w.getExternalIdentifiers().getExternalIdentifier().add(id);
    String bib = bibtexManager.generateBibtex(ORCID, w);
    Assert.assertEquals("OK", bib);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 25 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class BibtexManagerTest method testGenerateBibtexForSingleWorkEsaped.

@Test
public void testGenerateBibtexForSingleWorkEsaped() {
    Work w = new Work();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("Escapes θ à À È © ë Ö ì"));
    w.setWorkTitle(title);
    w.setWorkType(WorkType.JOURNAL_ARTICLE);
    w.setPutCode(100l);
    String bib = bibtexManager.generateBibtex(ORCID, w);
    Assert.assertEquals("@article{Credit_Name100,\ntitle={Escapes \\texttheta {\\`a} \\`{A} \\`{E} \\textcopyright {\\\"e} {\\\"O} {\\`i}},\nauthor={Credit Name}\n}", bib);
}
Also used : WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Work(org.orcid.jaxb.model.record_v2.Work) Title(org.orcid.jaxb.model.common_v2.Title) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)152 Work (org.orcid.jaxb.model.record_v2.Work)151 ClientResponse (com.sun.jersey.api.client.ClientResponse)56 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)35 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)26 DBUnitTest (org.orcid.test.DBUnitTest)25 Response (javax.ws.rs.core.Response)24 Title (org.orcid.jaxb.model.common_v2.Title)24 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)23 Url (org.orcid.jaxb.model.common_v2.Url)22 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)22 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)17 ArrayList (java.util.ArrayList)16 BaseTest (org.orcid.core.BaseTest)16 BulkElement (org.orcid.jaxb.model.record.bulk.BulkElement)16 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)15 Work (org.orcid.jaxb.model.record_rc1.Work)12 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)12 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)12 Work (org.orcid.jaxb.model.record_rc3.Work)11