Search in sources :

Example 16 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class PeerReviewManagerImpl method updatePeerReview.

@Override
public PeerReview updatePeerReview(String orcid, PeerReview peerReview, boolean isApiRequest) {
    PeerReviewEntity existingEntity = peerReviewDao.getPeerReview(orcid, peerReview.getPutCode());
    Visibility originalVisibility = existingEntity.getVisibility();
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    //Save the original source
    String existingSourceId = existingEntity.getSourceId();
    String existingClientSourceId = existingEntity.getClientSourceId();
    // If request comes from the API perform validations
    if (isApiRequest) {
        activityValidator.validatePeerReview(peerReview, sourceEntity, false, isApiRequest, originalVisibility);
        validateGroupId(peerReview);
        List<PeerReview> existingReviews = this.findPeerReviews(orcid, System.currentTimeMillis());
        for (PeerReview existing : existingReviews) {
            // Dont compare the updated peer review with the DB version
            if (!existing.getPutCode().equals(peerReview.getPutCode())) {
                activityValidator.checkExternalIdentifiersForDuplicates(peerReview.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), sourceManager.retrieveSourceEntity());
            }
        }
    } else {
        //check vocab of external identifiers
        externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
        externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
    }
    PeerReviewEntity updatedEntity = new PeerReviewEntity();
    orcidSecurityManager.checkSource(existingEntity);
    jpaJaxbPeerReviewAdapter.toPeerReviewEntity(peerReview, updatedEntity);
    updatedEntity.setProfile(new ProfileEntity(orcid));
    updatedEntity.setVisibility(originalVisibility);
    //Be sure it doesn't overwrite the source
    updatedEntity.setSourceId(existingSourceId);
    updatedEntity.setClientSourceId(existingClientSourceId);
    OrgEntity updatedOrganization = orgManager.getOrgEntity(peerReview);
    updatedEntity.setOrg(updatedOrganization);
    updatedEntity = peerReviewDao.merge(updatedEntity);
    peerReviewDao.flush();
    notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItem(updatedEntity));
    return jpaJaxbPeerReviewAdapter.toPeerReview(updatedEntity);
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Visibility(org.orcid.jaxb.model.common_v2.Visibility) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 17 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromMemberAPI.

@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
    String accessToken = getAccessToken();
    assertNotNull(accessToken);
    ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        //Educations
        if (record.getActivitiesSummary().getEducations() != null) {
            Educations e = record.getActivitiesSummary().getEducations();
            if (e.getSummaries() != null) {
                for (EducationSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Employments
        if (record.getActivitiesSummary().getEmployments() != null) {
            Employments e = record.getActivitiesSummary().getEmployments();
            if (e.getSummaries() != null) {
                for (EmploymentSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Fundings
        if (record.getActivitiesSummary().getFundings() != null) {
            Fundings f = record.getActivitiesSummary().getFundings();
            List<FundingGroup> groups = f.getFundingGroup();
            if (groups != null) {
                for (FundingGroup fGroup : groups) {
                    List<FundingSummary> summaries = fGroup.getFundingSummary();
                    if (summaries != null) {
                        for (FundingSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //PeerReviews
        if (record.getActivitiesSummary().getPeerReviews() != null) {
            PeerReviews p = record.getActivitiesSummary().getPeerReviews();
            List<PeerReviewGroup> groups = p.getPeerReviewGroup();
            if (groups != null) {
                for (PeerReviewGroup pGroup : groups) {
                    List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                    if (summaries != null) {
                        for (PeerReviewSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //Works
        if (record.getActivitiesSummary().getWorks() != null) {
            Works w = record.getActivitiesSummary().getWorks();
            List<WorkGroup> groups = w.getWorkGroup();
            if (groups != null) {
                for (WorkGroup wGroup : groups) {
                    List<WorkSummary> summaries = wGroup.getWorkSummary();
                    if (summaries != null) {
                        for (WorkSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertNotNull(o.getVisibility());
                    Visibility v = o.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                if (Visibility.PRIVATE.equals(b.getVisibility())) {
                    fail("Visibility is private");
                }
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        fail("Email " + e.getEmail() + " is private");
                    }
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            if (Visibility.PRIVATE.equals(name.getVisibility())) {
                fail("Name is private");
            }
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_rc2.Email) Keywords(org.orcid.jaxb.model.record_rc2.Keywords) Address(org.orcid.jaxb.model.record_rc2.Address) Fundings(org.orcid.jaxb.model.record.summary_rc2.Fundings) OtherNames(org.orcid.jaxb.model.record_rc2.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc2.PeerReviews) Name(org.orcid.jaxb.model.record_rc2.Name) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) Addresses(org.orcid.jaxb.model.record_rc2.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc2.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc2.FundingSummary) Biography(org.orcid.jaxb.model.record_rc2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc2.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc2.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc2.Emails) Works(org.orcid.jaxb.model.record.summary_rc2.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc2.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc2.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc2.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc2.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_rc2.Visibility) Test(org.junit.Test)

Example 18 with Visibility

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

Example 19 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class MemberV2Test method createViewUpdateAndDeleteEmployment.

@Test
public void createViewUpdateAndDeleteEmployment() throws JSONException, InterruptedException, URISyntaxException {
    Employment employment = (Employment) unmarshallFromPath("/record_2.0_rc2/samples/employment-2.0_rc2.xml", Employment.class);
    employment.setPutCode(null);
    employment.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createEmploymentXml(this.getUser1OrcidId(), employment, 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() + "/employment/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Employment gotEmployment = getResponse.getEntity(Employment.class);
    assertEquals("employment:department-name", gotEmployment.getDepartmentName());
    assertEquals("employment:role-title", gotEmployment.getRoleTitle());
    //Save the original visibility
    Visibility originalVisibility = gotEmployment.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotEmployment.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEmployment);
    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
    gotEmployment.setVisibility(originalVisibility);
    gotEmployment.setDepartmentName("updated dept. name");
    gotEmployment.setRoleTitle("updated role title");
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEmployment);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Employment gotAfterUpdateEmployment = getAfterUpdateResponse.getEntity(Employment.class);
    assertEquals("updated dept. name", gotAfterUpdateEmployment.getDepartmentName());
    assertEquals("updated role title", gotAfterUpdateEmployment.getRoleTitle());
    ClientResponse deleteResponse = memberV2ApiClient.deleteEmploymentXml(this.getUser1OrcidId(), gotEmployment.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_rc1.OrcidError) Employment(org.orcid.jaxb.model.record_rc2.Employment) Visibility(org.orcid.jaxb.model.common_rc2.Visibility) Test(org.junit.Test)

Example 20 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class MemberV2Test method createViewUpdateAndDeletePeerReview.

@Test
public void createViewUpdateAndDeletePeerReview() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc2/samples/peer-review-2.0_rc2.xml", PeerReview.class);
    peerReviewToCreate.setPutCode(null);
    peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
    peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId = new ExternalID();
    wExtId.setValue("Work Id " + time);
    wExtId.setType(WorkExternalIdentifierType.AGR.value());
    wExtId.setRelationship(Relationship.SELF);
    peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReviewToCreate, 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() + "/peer-review/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    PeerReview gotPeerReview = getResponse.getEntity(PeerReview.class);
    assertEquals("peer-review:url", gotPeerReview.getUrl().getValue());
    assertEquals("peer-review:subject-name", gotPeerReview.getSubjectName().getTitle().getContent());
    assertEquals(groupRecords.get(0).getGroupId(), gotPeerReview.getGroupId());
    //Save the original visibility
    Visibility originalVisibility = gotPeerReview.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotPeerReview.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotPeerReview);
    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
    gotPeerReview.setVisibility(originalVisibility);
    gotPeerReview.getSubjectName().getTitle().setContent("updated title");
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotPeerReview);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    PeerReview gotAfterUpdateWork = getAfterUpdateResponse.getEntity(PeerReview.class);
    assertEquals("updated title", gotAfterUpdateWork.getSubjectName().getTitle().getContent());
    assertEquals(groupRecords.get(0).getGroupId(), gotAfterUpdateWork.getGroupId());
    ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), gotAfterUpdateWork.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_rc1.OrcidError) ExternalID(org.orcid.jaxb.model.record_rc2.ExternalID) Visibility(org.orcid.jaxb.model.common_rc2.Visibility) PeerReview(org.orcid.jaxb.model.record_rc2.PeerReview) Test(org.junit.Test)

Aggregations

Visibility (org.orcid.jaxb.model.common_v2.Visibility)55 Test (org.junit.Test)36 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)12 HashMap (java.util.HashMap)10 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)10 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)9 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)8 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Date (java.util.Date)7 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)6 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5 Funding (org.orcid.jaxb.model.record_v2.Funding)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 Work (org.orcid.jaxb.model.record_v2.Work)5 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Visibility (org.orcid.jaxb.model.common_rc4.Visibility)4 OrcidError (org.orcid.jaxb.model.error_rc3.OrcidError)4 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4