use of org.orcid.internal.util.MemberInfo in project ORCID-Source by ORCID.
the class InternalApiServiceDelegatorImpl method viewMemberInfo.
@Override
public Response viewMemberInfo(String memberIdOrName) {
Member member = memberManager.getMember(memberIdOrName);
if (member == null || (member.getErrors() != null && !member.getErrors().isEmpty())) {
OrcidError orcidError = new OrcidError();
orcidError.setResponseCode(404);
orcidError.setErrorCode(0);
orcidError.setMoreInfo("Unable to find member info for: " + memberIdOrName);
orcidError.setDeveloperMessage("Member id or name not found for: " + memberIdOrName);
orcidError.setUserMessage("Unable to find member info for: " + memberIdOrName);
return Response.status(Response.Status.NOT_FOUND).entity(orcidError).build();
}
MemberInfo memberInfo = MemberInfo.fromMember(member);
return Response.ok(memberInfo).build();
}
use of org.orcid.internal.util.MemberInfo in project ORCID-Source by ORCID.
the class InternalApiServiceDelegatorTest method viewMemberInfo.
@Test
public void viewMemberInfo() {
String memberId = "5555-5555-5555-5558";
Response response = internalApiServiceDelegator.viewMemberInfo(memberId);
assertNotNull(response);
MemberInfo info = (MemberInfo) response.getEntity();
assertNotNull(info);
assertEquals(memberId, info.getId());
assertNotNull(info.getName());
assertNotNull(info.getClients());
assertFalse(info.getClients().isEmpty());
response = internalApiServiceDelegator.viewMemberInfo(info.getName());
assertNotNull(response);
MemberInfo infoByName = (MemberInfo) response.getEntity();
assertNotNull(infoByName);
assertEquals(memberId, infoByName.getId());
assertEquals(info, infoByName);
response = internalApiServiceDelegator.viewMemberInfo("invalid name");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
OrcidError error = (OrcidError) response.getEntity();
assertNotNull(error);
assertEquals(new Integer(0), error.getErrorCode());
assertEquals("Member id or name not found for: invalid name", error.getDeveloperMessage());
}
Aggregations