Search in sources :

Example 41 with Candidate

use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.

the class RegistrarManagerImplUnitTest method testParseMultipleTitlesAfter.

@Test
public void testParseMultipleTitlesAfter() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Vojtech Sassmann Dis. Csc.");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("sn", "Sassmann");
    fedData.put("givenName", "Vojtech");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    assertThat(candidate.getTitleBefore()).isEqualTo(null);
    assertThat(candidate.getTitleAfter()).isEqualTo("Dis. Csc.");
    assertThat(candidate.getFirstName()).isEqualTo("Vojtech");
    assertThat(candidate.getLastName()).isEqualTo("Sassmann");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 42 with Candidate

use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.

the class RegistrarManagerImplUnitTest method testDisplayNameWithMiddleNameAndFedData.

@Test
public void testDisplayNameWithMiddleNameAndFedData() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Bc. Vojtech Jan Sassmann Dis.");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("givenName", "Vojtech");
    fedData.put("sn", "Sassmann");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    assertThat(candidate.getTitleBefore()).isEqualTo("Bc.");
    assertThat(candidate.getTitleAfter()).isEqualTo("Dis.");
    assertThat(candidate.getFirstName()).isEqualTo("Vojtech");
    assertThat(candidate.getLastName()).isEqualTo("Sassmann");
    assertThat(candidate.getMiddleName()).isEqualTo("Jan");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 43 with Candidate

use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.

the class RegistrarManagerImplUnitTest method testParseMultipleTitlesBefore.

@Test
public void testParseMultipleTitlesBefore() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Bc. Mgr. Vojtech Sassmann");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("sn", "Sassmann");
    fedData.put("givenName", "Vojtech");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    assertThat(candidate.getTitleBefore()).isEqualTo("Bc. Mgr.");
    assertThat(candidate.getTitleAfter()).isEqualTo(null);
    assertThat(candidate.getFirstName()).isEqualTo("Vojtech");
    assertThat(candidate.getLastName()).isEqualTo("Sassmann");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 44 with Candidate

use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.

the class RegistrarManagerImplUnitTest method testDisplayNameReverseWithCommaAndFedData.

@Test
public void testDisplayNameReverseWithCommaAndFedData() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Bc. Sassmann, Vojtech Dis.");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("givenName", "Vojtech");
    fedData.put("sn", "Sassmann");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    assertThat(candidate.getTitleBefore()).isEqualTo("Bc.");
    assertThat(candidate.getTitleAfter()).isEqualTo("Dis.");
    assertThat(candidate.getMiddleName()).isEqualTo(null);
    assertThat(candidate.getLastName()).isEqualTo("Sassmann");
    assertThat(candidate.getFirstName()).isEqualTo("Vojtech");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 45 with Candidate

use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getAdmins.

@Test
public void getAdmins() throws Exception {
    System.out.println(CLASS_NAME + "getAdmins");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    // Set up resource admin
    member = setUpMember(vo);
    User user = perun.getUsersManagerBl().getUserByMember(sess, member);
    resourcesManager.addAdmin(sess, resource, user);
    // Set up resource admin group
    group = setUpGroup(vo, member);
    resourcesManager.addAdmin(sess, resource, group);
    // Set up second resource admin
    Candidate candidate = new Candidate();
    candidate.setFirstName("Josef");
    candidate.setId(4);
    candidate.setMiddleName("");
    candidate.setLastName("Novak");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    UserExtSource userExtSource = new UserExtSource(new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), Long.toHexString(Double.doubleToLongBits(Math.random())));
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<>());
    Member member2 = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
    User user2 = perun.getUsersManagerBl().getUserByMember(sess, member2);
    perun.getGroupsManager().addMember(sess, group, member2);
    // Test all admins
    List<User> admins = resourcesManager.getAdmins(sess, resource, false);
    assertTrue("list shoud have 2 admins", admins.size() == 2);
    assertTrue("our member as direct user should be admin", admins.contains(user));
    assertTrue("our member as member of admin group should be admin", admins.contains(user2));
    // Test only direct admins (without groups of admins)
    admins = resourcesManager.getAdmins(sess, resource, true);
    assertTrue("list should have only 1 admin", admins.size() == 1);
    assertTrue("our member as direct user should be in list of admins", admins.contains(user));
    assertTrue("our member as member of admin group shouldn't be in list of admins", !admins.contains(user2));
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) User(cz.metacentrum.perun.core.api.User) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AssignedMember(cz.metacentrum.perun.core.api.AssignedMember) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

Candidate (cz.metacentrum.perun.core.api.Candidate)100 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)52 Test (org.junit.Test)41 Member (cz.metacentrum.perun.core.api.Member)37 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)30 ExtSource (cz.metacentrum.perun.core.api.ExtSource)25 RichMember (cz.metacentrum.perun.core.api.RichMember)24 User (cz.metacentrum.perun.core.api.User)23 HashMap (java.util.HashMap)23 ArrayList (java.util.ArrayList)21 Group (cz.metacentrum.perun.core.api.Group)15 Attribute (cz.metacentrum.perun.core.api.Attribute)14 Map (java.util.Map)12 MemberCandidate (cz.metacentrum.perun.core.api.MemberCandidate)11 RichUser (cz.metacentrum.perun.core.api.RichUser)11 Vo (cz.metacentrum.perun.core.api.Vo)11 LinkedHashMap (java.util.LinkedHashMap)11 RichUserExtSource (cz.metacentrum.perun.core.api.RichUserExtSource)9 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)9 CandidateNotExistsException (cz.metacentrum.perun.core.api.exceptions.CandidateNotExistsException)8