Skip to content

Commit

Permalink
Merge pull request #6844 from ORCID/8761-qa-trusted-summary-json-inco…
Browse files Browse the repository at this point in the history
…mplete-employee-information

fix: Add status and fix organization name
  • Loading branch information
amontenegro authored Aug 1, 2023
2 parents 460fe0f + 0a70cee commit 8947b3f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static AffiliationSummary valueOf(org.orcid.jaxb.model.v3.release.record.
AffiliationSummary form = new AffiliationSummary();

if (as != null) {
if (as.getOrganization().getName() == null || as.getOrganization().getName().trim().length() == 0) {
if (as.getOrganization() != null && as.getOrganization().getName() != null && as.getOrganization().getName().trim().length() != 0) {
form.setOrganizationName(as.getOrganization().getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class RecordSummary {
private List<AffiliationSummary> professionalActivities;
private int professionalActivitiesCount;
private List<ExternalIdentifiersSummary> externalIdentifiers;
private String status;

public String getName() {
return name;
Expand Down Expand Up @@ -140,5 +141,11 @@ public void setExternalIdentifiers(List<ExternalIdentifiersSummary> externalIden
this.externalIdentifiers = externalIdentifiers;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ RecordSummary getSummaryRecord(@PathVariable("orcid") String orcid) {
// Check if the profile is deprecated or locked
orcidSecurityManager.checkProfile(orcid);
} catch (LockedException | DeactivatedException e) {
if (e instanceof LockedException) {
recordSummary.setStatus("locked");
} else {
recordSummary.setStatus("deactivated");
}
recordSummary.setName(localeManager.resolveMessage("public_profile.deactivated.given_names") + " "
+ localeManager.resolveMessage("public_profile.deactivated.family_name"));
return recordSummary;
Expand All @@ -338,11 +343,13 @@ RecordSummary getSummaryRecord(@PathVariable("orcid") String orcid) {
}

if (isDeprecated) {
recordSummary.setStatus("deprecated");
recordSummary.setEmploymentAffiliations(null);
recordSummary.setProfessionalActivities(null);
recordSummary.setExternalIdentifiers(null);
} else {
recordSummary = getSummary(orcid);
recordSummary.setStatus("active");
}

return recordSummary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

@RunWith(OrcidJUnit4ClassRunner.class)
@WebAppConfiguration
Expand All @@ -43,6 +44,7 @@ public class PublicRecordControllerTest extends DBUnitTest {
private String userOrcid = "0000-0000-0000-0003";
private String deprecatedUserOrcid = "0000-0000-0000-0004";
private String lockedUserOrcid = "0000-0000-0000-0006";
private String deactivatedUserOrcid = "0000-0000-0000-0007";

@Resource
PublicRecordController publicRecordController;
Expand All @@ -51,11 +53,9 @@ public class PublicRecordControllerTest extends DBUnitTest {
private LocaleManager localeManager;

@Mock
//private HttpServletRequest request;
private HttpServletRequest request = Mockito.mock(HttpServletRequest.class);

@Mock
//private HttpServletRequest request;
private HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

@Before
Expand Down Expand Up @@ -138,6 +138,9 @@ public void testGetRecordSummary() {
assertNotNull(record.getEmploymentAffiliations());
assertEquals(1, record.getEmploymentAffiliations().size());
assertEquals(1, record.getEmploymentAffiliationsCount());

assertEquals("An institution", record.getEmploymentAffiliations().get(0).getOrganizationName());

assertEquals(String.valueOf(13), record.getExternalIdentifiers().get(0).getId());
assertEquals("http://ext-id/public_ref", record.getExternalIdentifiers().get(0).getUrl());
assertFalse(record.getExternalIdentifiers().get(0).isValidatedOrSelfAsserted());
Expand All @@ -159,5 +162,35 @@ public void testGetRecordSummary() {
assertEquals(String.valueOf(13), record.getExternalIdentifiers().get(0).getId());
assertEquals("http://ext-id/public_ref", record.getExternalIdentifiers().get(0).getUrl());
assertFalse(record.getExternalIdentifiers().get(0).isValidatedOrSelfAsserted());

assertEquals("active", record.getStatus());
}

@Test
public void testGetRecordSummaryDeactivated() {
RecordSummary record = publicRecordController.getSummaryRecord(deactivatedUserOrcid);

assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());

assertEquals("deactivated", record.getStatus());
}

@Test
public void testGetRecordSummaryLocked() {
RecordSummary record = publicRecordController.getSummaryRecord(lockedUserOrcid);

assertNotNull(record.getName());
assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());

assertEquals("locked", record.getStatus());
}

@Test
public void testGetRecordSummaryDeprecated() {
RecordSummary record = publicRecordController.getSummaryRecord(deprecatedUserOrcid);

assertNull(record.getName());

assertEquals("deprecated", record.getStatus());
}
}

0 comments on commit 8947b3f

Please sign in to comment.