use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ResultContainer method getEmptyGroup.
/**
* Get an empty group
*
* @return an empty group
* */
@RequestMapping(value = "/member.json", method = RequestMethod.GET)
@ResponseBody
public Member getEmptyGroup() {
Text empty = Text.valueOf("");
Member group = new Member();
group.setEmail(empty);
group.setGroupName(empty);
group.setGroupOrcid(empty);
group.setSalesforceId(empty);
// Set the default type as basic
group.setType(Text.valueOf(MemberType.BASIC.value()));
return group;
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method findMemberByOrcidTest.
@Test
public void findMemberByOrcidTest() throws Exception {
Member group = new Member();
group.setEmail(Text.valueOf("group@email.com"));
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("premium-institution"));
group.setSalesforceId(Text.valueOf("1234567890abcde"));
group = manageMembers.createMember(group);
assertEquals(0, group.getErrors().size());
assertFalse(PojoUtil.isEmpty(group.getGroupOrcid()));
// Test find by orcid
String orcid = group.getGroupOrcid().getValue();
Member newGroup = manageMembers.findMember(orcid);
assertNotNull(newGroup);
assertFalse(PojoUtil.isEmpty(newGroup.getGroupOrcid()));
assertFalse(PojoUtil.isEmpty(newGroup.getEmail()));
assertFalse(PojoUtil.isEmpty(newGroup.getSalesforceId()));
assertFalse(PojoUtil.isEmpty(newGroup.getGroupName()));
assertEquals("group@email.com", newGroup.getEmail().getValue());
assertEquals("Group Name", newGroup.getGroupName().getValue());
assertEquals("1234567890abcde", newGroup.getSalesforceId().getValue());
assertEquals(orcid, newGroup.getGroupOrcid().getValue());
// Test find by email
Member newGroup2 = manageMembers.findMember("group@email.com");
assertNotNull(newGroup2);
assertFalse(PojoUtil.isEmpty(newGroup2.getGroupOrcid()));
assertFalse(PojoUtil.isEmpty(newGroup2.getEmail()));
assertFalse(PojoUtil.isEmpty(newGroup2.getSalesforceId()));
assertFalse(PojoUtil.isEmpty(newGroup2.getGroupName()));
assertEquals("group@email.com", newGroup2.getEmail().getValue());
assertEquals("Group Name", newGroup2.getGroupName().getValue());
assertEquals("1234567890abcde", newGroup2.getSalesforceId().getValue());
assertEquals(orcid, newGroup2.getGroupOrcid().getValue());
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method editGroupTypeTest.
@Test
public void editGroupTypeTest() throws Exception {
Member group_0000 = manageMembers.findMember("5555-5555-5555-0000");
assertNotNull(group_0000);
assertNotNull(group_0000.getType());
assertEquals(MemberType.PREMIUM_INSTITUTION.value(), group_0000.getType().getValue());
// Update group type to basic
group_0000.setType(Text.valueOf(MemberType.BASIC.value()));
manageMembers.updateMember(group_0000);
group_0000 = manageMembers.findMember("5555-5555-5555-0000");
assertNotNull(group_0000);
assertNotNull(group_0000.getType());
assertEquals(MemberType.BASIC.value(), group_0000.getType().getValue());
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method createMemberProfileWithInvalidGroupNameTest.
@Test
public void createMemberProfileWithInvalidGroupNameTest() throws Exception {
Member group = new Member();
group.setEmail(Text.valueOf("group@email.com"));
group.setType(Text.valueOf("basic"));
group.setSalesforceId(Text.valueOf(""));
// Validate empty group name
group.setGroupName(Text.valueOf(""));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("NotBlank.group.name", new ArrayList<String>()), group.getErrors().get(0));
// validate too long group name - 151 chars
group.setGroupName(Text.valueOf("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.name.too_long", new ArrayList<String>()), group.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method createMemberProfileWithInvalidTypeTest.
@Test
public void createMemberProfileWithInvalidTypeTest() throws Exception {
Member group = new Member();
group.setEmail(Text.valueOf("group@email.com"));
group.setGroupName(Text.valueOf("Group Name"));
group.setSalesforceId(Text.valueOf(""));
// Validate empty type
group.setType(Text.valueOf(""));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("NotBlank.group.type", new ArrayList<String>()), group.getErrors().get(0));
// Validate invalid type
group.setType(Text.valueOf("invalid"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.type.invalid", new ArrayList<String>()), group.getErrors().get(0));
}
Aggregations