use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class VosManagerEntryIntegrationTest method getCompleteCandidatesFromGroupWithNullVo.
@Test
public void getCompleteCandidatesFromGroupWithNullVo() throws Exception {
System.out.println(CLASS_NAME + "getCompleteCandidatesFromGroupWithNullVo");
// create group and vo
myVo = perun.getVosManagerBl().createVo(sess, myVo);
Group group = new Group("testGroup", "testingGroup");
Group returnedGroup = perun.getGroupsManager().createGroup(sess, myVo, group);
// prepare second extSource
ExtSource extSource = new ExtSource("testExtSource", ExtSourcesManager.EXTSOURCE_INTERNAL);
extSource = perun.getExtSourcesManagerBl().createExtSource(sess, extSource, null);
// prepare users to be returned by getCompleteCandidates
Candidate candidate = prepareCandidateWithExtSource("Jan", es);
User userToContain1 = perun.getUsersManagerBl().getRichUser(sess, perun.getUsersManagerBl().createUser(sess, candidate));
candidate = prepareCandidateWithExtSource("Josef", es);
User userNotToContain1 = perun.getUsersManagerBl().getRichUser(sess, perun.getUsersManagerBl().createUser(sess, candidate));
candidate = prepareCandidateWithExtSource("Jana", extSource);
RichUser userToContain2 = perun.getUsersManagerBl().getRichUser(sess, perun.getUsersManagerBl().createUser(sess, candidate));
List<MemberCandidate> completeCandidates = perun.getVosManagerBl().getCompleteCandidates(sess, null, returnedGroup, null, "jan", Arrays.asList(es));
List<RichUser> usersOfCompleteCandidates = completeCandidates.stream().map(MemberCandidate::getRichUser).collect(Collectors.toList());
assertEquals("Three users should have been returned.", 2, usersOfCompleteCandidates.size());
assertTrue("User should've been returned.", usersOfCompleteCandidates.contains(userToContain1));
assertTrue("User should've been returned.", usersOfCompleteCandidates.contains(userToContain2));
assertFalse("User shouldn't have been returned.", usersOfCompleteCandidates.contains(userNotToContain1));
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method testCreateServiceUserFailsForAlreadyExistingUes.
@Test
public void testCreateServiceUserFailsForAlreadyExistingUes() throws Exception {
System.out.println(CLASS_NAME + "testCreateServiceUserFailsForAlreadyExistingUes");
Candidate candidate = setUpCandidateForSpecificUser1();
usersManager.createServiceUser(sess, candidate, Collections.emptyList());
assertThatExceptionOfType(UserExtSourceExistsException.class).isThrownBy(() -> usersManager.createServiceUser(sess, candidate, Collections.emptyList()));
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest 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()));
Candidate candidate;
// Mockito.mock(Candidate.class);
candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
UserExtSource ues = new UserExtSource(new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), extLogin);
candidate.setUserExtSource(ues);
candidate.setAttributes(new HashMap<>());
Member createdMember = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
assertNotNull("No member created", createdMember);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, createdMember));
// save user for deletion after test
return createdMember;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method setUpMember.
private Member setUpMember(Vo vo) throws Exception {
// List<Candidate> candidates = perun.getVosManager().findCandidates(sess, vo, extLogin);
// find candidates from ext source based on extLogin
// assertTrue(candidates.size() > 0);
Candidate candidate = setUpCandidate();
// candidates.get(0)
Member member = perun.getMembersManagerBl().createMember(sess, vo, candidate);
perun.getMembersManagerBl().validateMember(sess, member);
// set first candidate as member of test VO
assertNotNull("No member created", member);
usersForDeletion.add(usersManager.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 UsersManagerEntryIntegrationTest method setUpCandidateForSpecificUser1.
private Candidate setUpCandidateForSpecificUser1() {
// Mockito.mock(Candidate.class);
Candidate candidate = new Candidate();
candidate.setFirstName("(Service)");
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName("testingServiceUser01");
candidate.setTitleBefore("");
candidate.setTitleAfter("");
candidate.setServiceUser(true);
final UserExtSource userExtSource = new UserExtSource(extSource, Long.toHexString(Double.doubleToLongBits(Math.random())));
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
return candidate;
}
Aggregations