Search in sources :

Example 1 with Member

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();
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) MemberInfo(org.orcid.internal.util.MemberInfo) Member(org.orcid.pojo.ajaxForm.Member)

Example 2 with Member

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

Example 3 with Member

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

Example 4 with Member

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

Example 5 with Member

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));
}
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)14 Test (org.junit.Test)10 DBUnitTest (org.orcid.test.DBUnitTest)10 ArrayList (java.util.ArrayList)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 MemberType (org.orcid.jaxb.model.clientgroup.MemberType)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Transactional (javax.transaction.Transactional)1 MemberInfo (org.orcid.internal.util.MemberInfo)1 Client (org.orcid.jaxb.model.client_v2.Client)1 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)1 Client (org.orcid.jaxb.model.v3.dev1.client.Client)1 Text (org.orcid.pojo.ajaxForm.Text)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1