Search in sources :

Example 31 with Url

use of org.orcid.jaxb.model.common_rc1.Url in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testEmptyRelationshipOnFundingExternalIds_flagOff.

@Test
public void testEmptyRelationshipOnFundingExternalIds_flagOff() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(null);
    id1.setType("grant_number");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalIDs ids = new ExternalIDs();
    ids.getExternalIdentifier().add(id1);
    validator.validateFunding(ids);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 32 with Url

use of org.orcid.jaxb.model.common_rc1.Url in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testEmptyRelationshipOnExternalIds_flagOn.

@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnExternalIds_flagOn() {
    validator.setRequireRelationshipOnExternalIdentifier(true);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(null);
    id2.setType("doi");
    id2.setValue("value1");
    id2.setUrl(new Url("http://value1.com"));
    ExternalID id3 = new ExternalID();
    id3.setRelationship(Relationship.SELF);
    id3.setType("doi");
    id3.setValue("value1");
    id3.setUrl(new Url("http://value1.com"));
    extIds.getExternalIdentifier().add(id1);
    extIds.getExternalIdentifier().add(id2);
    extIds.getExternalIdentifier().add(id3);
    validator.validateWorkOrPeerReview(extIds);
    fail("no exception thrown for invalid type");
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 33 with Url

use of org.orcid.jaxb.model.common_rc1.Url in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testEmptyRelationshipOnFundingExternalIds_flagOn.

@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnFundingExternalIds_flagOn() {
    validator.setRequireRelationshipOnExternalIdentifier(true);
    ExternalID id1 = new ExternalID();
    id1.setRelationship(null);
    id1.setType("grant_number");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalIDs ids = new ExternalIDs();
    ids.getExternalIdentifier().add(id1);
    validator.validateFunding(ids);
    fail("no exception thrown for invalid type");
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 34 with Url

use of org.orcid.jaxb.model.common_rc1.Url in project ORCID-Source by ORCID.

the class PersonValidatorTest method validateExternalIdentifier_invalidUrl_emptyUrlTest.

@Test(expected = OrcidValidationException.class)
public void validateExternalIdentifier_invalidUrl_emptyUrlTest() {
    PersonExternalIdentifier extId = getPersonExternalIdentifier();
    extId.setUrl(new Url());
    PersonValidator.validateExternalIdentifier(extId, getSourceEntity(), true, true, Visibility.PUBLIC, true);
    fail();
}
Also used : PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 35 with Url

use of org.orcid.jaxb.model.common_rc1.Url in project ORCID-Source by ORCID.

the class WorksTest method createViewUpdateAndDeleteWork.

@Test
public void createViewUpdateAndDeleteWork() throws JSONException, InterruptedException, URISyntaxException {
    changeDefaultUserVisibility(webDriver, org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    long time = System.currentTimeMillis();
    Work workToCreate = (Work) unmarshallFromPath("/record_2.0_rc2/samples/work-2.0_rc2.xml", Work.class);
    workToCreate.setPutCode(null);
    workToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId = new ExternalID();
    wExtId.setValue("Work Id " + time);
    wExtId.setType("agr");
    wExtId.setRelationship(Relationship.SELF);
    wExtId.setUrl(new Url("http://test.orcid.org/" + time));
    workToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), workToCreate, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc2/" + this.getUser1OrcidId() + "/work/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Work gotWork = getResponse.getEntity(Work.class);
    assertEquals("common:title", gotWork.getWorkTitle().getTitle().getContent());
    assertEquals("work:citation", gotWork.getWorkCitation().getCitation());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, gotWork.getWorkCitation().getWorkCitationType());
    gotWork.getWorkTitle().getTitle().setContent("updated title");
    //Save the original visibility
    Visibility originalVisibility = gotWork.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotWork.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotWork);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    OrcidError error = putResponse.getEntity(OrcidError.class);
    assertNotNull(error);
    assertEquals(Integer.valueOf(9035), error.getErrorCode());
    //Set the visibility again to the initial one
    gotWork.setVisibility(originalVisibility);
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotWork);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Work gotAfterUpdateWork = getAfterUpdateResponse.getEntity(Work.class);
    assertEquals("updated title", gotAfterUpdateWork.getWorkTitle().getTitle().getContent());
    assertEquals("work:citation", gotAfterUpdateWork.getWorkCitation().getCitation());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, gotAfterUpdateWork.getWorkCitation().getWorkCitationType());
    ClientResponse deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), gotWork.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidError(org.orcid.jaxb.model.error_rc2.OrcidError) ExternalID(org.orcid.jaxb.model.record_rc2.ExternalID) Work(org.orcid.jaxb.model.record_rc2.Work) Visibility(org.orcid.jaxb.model.common_rc2.Visibility) Url(org.orcid.jaxb.model.common_rc2.Url) Test(org.junit.Test)

Aggregations

Url (org.orcid.jaxb.model.common_v2.Url)86 Test (org.junit.Test)84 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)55 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)30 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)24 Title (org.orcid.jaxb.model.common_v2.Title)23 Work (org.orcid.jaxb.model.record_v2.Work)21 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)20 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)18 Validator (javax.xml.validation.Validator)16 Funding (org.orcid.jaxb.model.record_v2.Funding)15 ArrayList (java.util.ArrayList)14 Url (org.orcid.jaxb.model.common_rc3.Url)11 Url (org.orcid.jaxb.model.common_rc4.Url)11 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)11 Response (javax.ws.rs.core.Response)10 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)10 DBUnitTest (org.orcid.test.DBUnitTest)10 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)9