use of org.orcid.pojo.ajaxForm.Member 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.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method createMemberProfileWithInvalidSalesforceIdTest.
@Test
public void createMemberProfileWithInvalidSalesforceIdTest() throws Exception {
Member group = new Member();
group.setEmail(Text.valueOf("group@email.com"));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("basic"));
// Validate empty type
group.setSalesforceId(Text.valueOf("1"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.salesforce_id.invalid_length", new ArrayList<String>()), group.getErrors().get(0));
// Validate invalid type
group.setSalesforceId(Text.valueOf("1234567890abcd!"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.salesforce_id.invalid", new ArrayList<String>()), group.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method editMemberWithInvalidSalesforceIdTest.
@Test
public void editMemberWithInvalidSalesforceIdTest() throws Exception {
// Create one member
Member group = new Member();
String email = "group" + System.currentTimeMillis() + "@email.com";
group.setEmail(Text.valueOf(email));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("premium-institution"));
group.setSalesforceId(Text.valueOf("1234567890abcde"));
group = manageMembers.createMember(group);
assertNotNull(group);
assertEquals(0, group.getErrors().size());
// Try to create another member with the same email
group = new Member();
group.setEmail(Text.valueOf("group2@email.com"));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("premium-institution"));
group.setSalesforceId(Text.valueOf("1234567890abcd!"));
group = manageMembers.createMember(group);
assertNotNull(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.salesforce_id.invalid", new ArrayList<String>()), group.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method createMemberProfileWithInvalidEmailsTest.
@Test
@Transactional
public void createMemberProfileWithInvalidEmailsTest() throws Exception {
ProfileEntity profile = profileDao.find("5555-5555-5555-0000");
assertNotNull(profile);
assertNotNull(profile.getPrimaryEmail());
String existingEmail = profile.getPrimaryEmail().getId();
assertNotNull(existingEmail);
Member group = new Member();
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("basic"));
group.setSalesforceId(Text.valueOf(""));
// Validate already existing email address
group.setEmail(Text.valueOf(existingEmail));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.email.already_used", new ArrayList<String>()), group.getErrors().get(0));
// Validate empty email address
group.setEmail(Text.valueOf(""));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("NotBlank.group.email", new ArrayList<String>()), group.getErrors().get(0));
// Validate invalid email address
group.setEmail(Text.valueOf("invalidemail"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.email.invalid_email", new ArrayList<String>()), group.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method editMemberWithInvalidEmailTest.
@Test
public void editMemberWithInvalidEmailTest() throws Exception {
// Create one member
Member group = new Member();
String email = "group" + System.currentTimeMillis() + "@email.com";
group.setEmail(Text.valueOf(email));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("premium-institution"));
group.setSalesforceId(Text.valueOf("1234567890abcde"));
group = manageMembers.createMember(group);
assertNotNull(group);
assertEquals(0, group.getErrors().size());
// Try to create another member with the same email
group = new Member();
group.setEmail(Text.valueOf(email));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("premium-institution"));
group.setSalesforceId(Text.valueOf("1234567890abcde"));
group = manageMembers.createMember(group);
assertNotNull(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.email.already_used", new ArrayList<String>()), group.getErrors().get(0));
}
Aggregations