Search in sources :

Example 6 with Member

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;
}
Also used : Text(org.orcid.pojo.ajaxForm.Text) Member(org.orcid.pojo.ajaxForm.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Member

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());
}
Also used : Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with Member

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());
}
Also used : Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with Member

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));
}
Also used : ArrayList(java.util.ArrayList) Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Member

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));
}
Also used : ArrayList(java.util.ArrayList) Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Member (org.orcid.pojo.ajaxForm.Member)13 Test (org.junit.Test)10 DBUnitTest (org.orcid.test.DBUnitTest)10 ArrayList (java.util.ArrayList)6 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)1 MemberInfo (org.orcid.internal.util.MemberInfo)1 MemberType (org.orcid.jaxb.model.clientgroup.MemberType)1 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1 Text (org.orcid.pojo.ajaxForm.Text)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1