Search in sources :

Example 31 with Candidate

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;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 32 with 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"));
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) Group(cz.metacentrum.perun.core.api.Group) VosManager(cz.metacentrum.perun.core.api.VosManager) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) Before(org.junit.Before)

Example 33 with Candidate

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));
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) User(cz.metacentrum.perun.core.api.User) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 34 with Candidate

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;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) Member(cz.metacentrum.perun.core.api.Member)

Example 35 with Candidate

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);
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) MemberCandidate(cz.metacentrum.perun.core.api.MemberCandidate) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) Vo(cz.metacentrum.perun.core.api.Vo) Ignore(org.junit.Ignore) 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