use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method setUpCandidateNotSponsor.
private Candidate setUpCandidateNotSponsor() {
String userFirstName = "Petr";
String userLastName = "Nesponzor";
String extLogin = "cccccc";
// Mockito.mock(Candidate.class);
Candidate candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("RNDr.");
candidate.setTitleAfter("Ph.D.");
final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
return candidate;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
extSource = perun.getExtSourcesManager().createExtSource(sess, extSource, null);
usersManagerEntry = perun.getUsersManager();
attributesManagerEntry = perun.getAttributesManager();
membersManagerEntry = perun.getMembersManager();
final Vo vo = new Vo(0, "m3mb3r r00m", "m3mber-room");
VosManager vosManagerEntry = perun.getVosManager();
createdVo = vosManagerEntry.createVo(sess, vo);
assertNotNull(createdVo);
groupsManagerEntry = perun.getGroupsManager();
final Group group = new Group("Test_Group_123456", "TestGroupDescr");
createdGroup = groupsManagerEntry.createGroup(sess, createdVo, group);
String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
// his login in external source
String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
// Mockito.mock(Candidate.class);
candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
ues = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(ues);
candidate.setAttributes(new HashMap<>());
createdMember = perun.getMembersManagerBl().createMemberSync(sess, createdVo, candidate);
assertNotNull("No member created", createdMember);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, createdMember));
// save user for deletion after test
// need for testing creating members
g1 = perun.getGroupsManagerBl().createGroup(sess, createdVo, new Group("TESTINGGROUP1", "TESTINGGROUP1"));
g2 = perun.getGroupsManagerBl().createGroup(sess, createdVo, new Group("TESTINGGROUP2", "TESTINGGROUP2"));
g3ing1 = perun.getGroupsManagerBl().createGroup(sess, g1, new Group("TESTINGGROUP3", "TESTINGGROUP3"));
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method findMemberByName.
@Test
public void findMemberByName() throws Exception {
System.out.println(CLASS_NAME + "findMemberByName");
Member member = setUpMember(createdVo);
User user = perun.getUsersManagerBl().getUserByMember(sess, member);
List<Member> members = perun.getMembersManagerBl().findMembers(sess, createdVo, user.getFirstName(), false);
assertTrue(members.size() == 1);
assertEquals(member, members.get(0));
members = perun.getMembersManagerBl().findMembers(sess, createdVo, user.getLastName(), false);
assertTrue(members.size() == 1);
assertEquals(member, members.get(0));
members = perun.getMembersManagerBl().findMembers(sess, createdVo, user.getLastName() + " " + user.getFirstName(), false);
assertTrue(members.size() == 1);
assertEquals(member, members.get(0));
// New member to test searching with space in first name
Candidate candidate2 = new Candidate();
// Different first name from the default candidate in the test, contains a space
candidate2.setFirstName(new StringBuilder(candidate.getFirstName()).append('2').insert(candidate.getFirstName().length() / 2, ' ').toString());
candidate2.setId(0);
candidate2.setMiddleName("");
candidate2.setLastName(candidate.getLastName());
candidate2.setTitleBefore("");
candidate2.setTitleAfter("");
// Different ext login from the default candidate in the test
UserExtSource ues2 = new UserExtSource(extSource, candidate.getUserExtSource().getLogin() + "2");
candidate2.setUserExtSource(ues2);
candidate2.setAttributes(new HashMap<>());
Member member2 = perun.getMembersManagerBl().createMemberSync(sess, createdVo, candidate2);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member2));
assertNotNull("No member created", member2);
members = perun.getMembersManagerBl().findMembers(sess, createdVo, candidate2.getFirstName(), false);
assertTrue(members.size() == 1);
assertEquals(member2, members.get(0));
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class ModulesUtilsEntryIntegrationTest method setUpMember.
private Member setUpMember() throws Exception {
String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
// his login in external source
String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
// Mockito.mock(Candidate.class);
Candidate candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
UserExtSource userExtSource = new UserExtSource(new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
Member member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
assertNotNull("No member created", member);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member));
// save user for deletion after test
return member;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class VosManagerEntryIntegrationTest method findCandidates.
@Test
@Ignore
public void findCandidates() throws Exception {
System.out.println(CLASS_NAME + "findCandidates");
final Vo createdVo = vosManagerEntry.createVo(sess, myVo);
addExtSourceDelegate(createdVo);
final List<Candidate> candidates = vosManagerEntry.findCandidates(sess, createdVo, "kouril");
// TODO tohle se mi moc nelibi, kde se nejaci candidates vzali? To by
// bylo dobre plnit na zacatku testu db nebo je vytvorit rucne zde
assertTrue("Candidates count must be greater than 0", candidates.size() > 0);
removeExtSourceDelegate(createdVo);
}
Aggregations