Search in sources :

Example 11 with OrcidIdentifier

use of org.orcid.jaxb.model.common_v2.OrcidIdentifier in project ORCID-Source by ORCID.

the class S3UpdaterTest method updateS3_RecordTest.

@Test
public void updateS3_RecordTest() throws JAXBException, AmazonClientException, IOException {
    String bucketPrefix = "bucket-production";
    String orcid = "0000-0000-0000-000X";
    Record record = new Record();
    record.setOrcidIdentifier(new OrcidIdentifier(orcid));
    S3Updater s3 = new S3Updater(bucketPrefix);
    s3.setS3MessagingService(s3MessagingService);
    s3.updateS3(orcid, record);
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-1-2-json-x"), Matchers.eq(orcid + ".json"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(0)).send(Matchers.eq(bucketPrefix + "-api-1-2-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(1)).send(Matchers.eq(bucketPrefix + "-api-2-0-json-x"), Matchers.eq(orcid + ".json"), Matchers.any(), Matchers.any());
    verify(s3MessagingService, times(1)).send(Matchers.eq(bucketPrefix + "-api-2-0-xml-x"), Matchers.eq(orcid + ".xml"), Matchers.any(), Matchers.any());
}
Also used : S3Updater(org.orcid.listener.s3.S3Updater) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) Record(org.orcid.jaxb.model.record_v2.Record) Test(org.junit.Test)

Example 12 with OrcidIdentifier

use of org.orcid.jaxb.model.common_v2.OrcidIdentifier in project ORCID-Source by ORCID.

the class MongoMessageProcessorTest method testDeactivated.

@Test
public void testDeactivated() throws LockedRecordException, DeprecatedRecordException, DatatypeConfigurationException {
    Record deactivatedRecord = new Record();
    deactivatedRecord.setOrcidIdentifier(new OrcidIdentifier("http://orcid.org/" + this.orcid2));
    History h = new History();
    h.setDeactivationDate(new DeactivationDate());
    GregorianCalendar c = new GregorianCalendar();
    XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    h.getDeactivationDate().setValue(date);
    deactivatedRecord.setHistory(h);
    when(mock_orcid20ApiClient.fetchPublicRecord(Matchers.any())).thenReturn(deactivatedRecord);
    LastModifiedMessage m = new LastModifiedMessage(this.orcid2, new Date());
    mongo.accept(m);
    // test db has entry for deactivated record
    Document d = new Document();
    d.put("_id", this.orcid2);
    assertEquals(col.count(d), 1);
    FindIterable<Document> it = col.find(d);
    assertEquals(it.first().get("status"), "deactivated");
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) LastModifiedMessage(org.orcid.utils.listener.LastModifiedMessage) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Record(org.orcid.jaxb.model.record_v2.Record) History(org.orcid.jaxb.model.record_v2.History) Document(org.bson.Document) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) Test(org.junit.Test)

Example 13 with OrcidIdentifier

use of org.orcid.jaxb.model.common_v2.OrcidIdentifier in project ORCID-Source by ORCID.

the class v2ClientPerMessageCacheTest method before.

@Before
public void before() {
    MockitoAnnotations.initMocks(this);
    TargetProxyHelper.injectIntoProxy(orcid20ApiClient, "jerseyClient", mock_jerseyClient);
    // mock methods
    when(mock_jerseyClient.resource(Matchers.isA(URI.class))).thenReturn(mock_resource);
    when(mock_resource.path(Matchers.anyString())).thenReturn(mock_resource);
    when(mock_resource.accept(Matchers.anyString())).thenReturn(mock_builder);
    when(mock_builder.get(Matchers.isA(Class.class))).thenReturn(mock_response);
    when(mock_builder.header(Matchers.anyString(), Matchers.anyString())).thenReturn(mock_builder);
    when(mock_response.getStatus()).thenReturn(200);
    when(mock_response.getEntity(Record.class)).thenReturn(record);
    // build test record
    record.setOrcidIdentifier(new OrcidIdentifier("http://orcid.org/0000-0000-0000-0000"));
    ActivitiesSummary sum = new ActivitiesSummary();
    Works works = new Works();
    WorkGroup group = new WorkGroup();
    WorkSummary work = new WorkSummary();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("blah"));
    work.setTitle(title);
    group.getWorkSummary().add(work);
    works.getWorkGroup().add(group);
    sum.setWorks(works);
    record.setActivitiesSummary(sum);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Works(org.orcid.jaxb.model.record.summary_v2.Works) URI(java.net.URI) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Before(org.junit.Before)

Example 14 with OrcidIdentifier

use of org.orcid.jaxb.model.common_v2.OrcidIdentifier in project ORCID-Source by ORCID.

the class PublicV2ApiServiceVersionedDelegatorTest method testSearchByQuery.

@Test
public void testSearchByQuery() {
    MockitoAnnotations.initMocks(this);
    Search search = new Search();
    Result result = new Result();
    result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
    search.getResults().add(result);
    Response searchResponse = Response.ok(search).build();
    Mockito.when(mockServiceDelegatorNonVersioned.searchByQuery(Matchers.<Map<String, List<String>>>any())).thenReturn(searchResponse);
    TargetProxyHelper.injectIntoProxy(serviceDelegator, "publicV2ApiServiceDelegator", mockServiceDelegatorNonVersioned);
    Response response = serviceDelegator.searchByQuery(new HashMap<String, List<String>>());
    // just testing MemberV2ApiServiceDelegatorImpl's response is returned
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertTrue(response.getEntity() instanceof Search);
    assertEquals(1, ((Search) response.getEntity()).getResults().size());
    assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
    TargetProxyHelper.injectIntoProxy(serviceDelegator, "publicV2ApiServiceDelegator", serviceDelegatorNonVersioned);
}
Also used : Response(javax.ws.rs.core.Response) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) Search(org.orcid.jaxb.model.search_v2.Search) List(java.util.List) ArrayList(java.util.ArrayList) Result(org.orcid.jaxb.model.search_v2.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 15 with OrcidIdentifier

use of org.orcid.jaxb.model.common_v2.OrcidIdentifier in project ORCID-Source by ORCID.

the class RDFWriterTest method fakeBio.

private Record fakeBio() throws DatatypeConfigurationException {
    Record r = new Record();
    r.setOrcidIdentifier(new OrcidIdentifier());
    r.getOrcidIdentifier().setPath("000-1337");
    r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
    r.setHistory(new History());
    r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
    r.getHistory().setClaimed(true);
    r.setPerson(new Person());
    r.getPerson().setBiography(new Biography());
    r.getPerson().setName(new Name());
    r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
    r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
    r.getPerson().getName().setGivenNames(new GivenNames("John"));
    r.getPerson().setOtherNames(new OtherNames());
    r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
    OtherName n = new OtherName();
    n.setContent("Johnny");
    n.setVisibility(Visibility.PUBLIC);
    OtherName n1 = new OtherName();
    n1.setContent("Mr Doe");
    n1.setVisibility(Visibility.PUBLIC);
    r.getPerson().getOtherNames().getOtherNames().add(n);
    r.getPerson().getOtherNames().getOtherNames().add(n1);
    r.getPerson().setResearcherUrls(new ResearcherUrls());
    r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
    ResearcherUrl anonymous = new ResearcherUrl();
    anonymous.setUrl(new Url("http://example.com/anon"));
    anonymous.setVisibility(Visibility.PUBLIC);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
    r.getPerson().setAddresses(new Addresses());
    r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
    Address a = new Address();
    a.setCountry(new Country());
    a.getCountry().setValue(Iso3166Country.GB);
    r.getPerson().getAddresses().getAddress().add(a);
    r.getPerson().setEmails(new Emails());
    r.getPerson().getEmails().setEmails(new ArrayList<Email>());
    Email e = new Email();
    e.setEmail("john@example.org");
    e.setCurrent(true);
    Email e1 = new Email();
    e1.setEmail("doe@example.com");
    e1.setCurrent(true);
    r.getPerson().getEmails().getEmails().add(e);
    r.getPerson().getEmails().getEmails().add(e1);
    return r;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) History(org.orcid.jaxb.model.record_v2.History) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Person(org.orcid.jaxb.model.record_v2.Person)

Aggregations

OrcidIdentifier (org.orcid.jaxb.model.common_v2.OrcidIdentifier)13 Test (org.junit.Test)10 Response (javax.ws.rs.core.Response)6 DBUnitTest (org.orcid.test.DBUnitTest)6 List (java.util.List)5 History (org.orcid.jaxb.model.record_v2.History)5 Record (org.orcid.jaxb.model.record_v2.Record)5 ArrayList (java.util.ArrayList)4 Result (org.orcid.jaxb.model.search_v2.Result)4 Search (org.orcid.jaxb.model.search_v2.Search)4 Date (java.util.Date)3 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)3 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)3 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 Document (org.bson.Document)2 OrcidSearchManager (org.orcid.core.manager.OrcidSearchManager)2 OrcidSecurityManager (org.orcid.core.manager.OrcidSecurityManager)2 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 Title (org.orcid.jaxb.model.common_v2.Title)2