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");
}
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");
}
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");
}
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");
}
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));
}
Aggregations