Search in sources :

Example 56 with Candidate

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

the class MembersManagerEntryIntegrationTest method createMemberFromCandidateInGroup.

@Test
public void createMemberFromCandidateInGroup() throws Exception {
    System.out.println(CLASS_NAME + "createMember");
    // Create vo and groups
    // g3in1 - direct, g1 indirect
    List<Group> groups = new ArrayList<>(Collections.singletonList(g3ing1));
    // Create new locale member for puprose of this method
    String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
    String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
    String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
    Candidate 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", ExtSourcesManager.EXTSOURCE_INTERNAL), extLogin);
    candidate.setUserExtSource(ues);
    candidate.setAttributes(new HashMap<>());
    Member member = perun.getMembersManager().createMember(sess, createdVo, candidate, groups);
    // test if member is in vo and also in defined groups
    assertTrue(perun.getMembersManagerBl().getMembers(sess, createdVo).contains(member));
    List<Group> returnedGroups = perun.getGroupsManagerBl().getMemberGroups(sess, member);
    assertTrue(returnedGroups.contains(g1));
    assertTrue(!returnedGroups.contains(g2));
    assertTrue(returnedGroups.contains(g3ing1));
    // save user for deletion after test
    usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member));
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) Group(cz.metacentrum.perun.core.api.Group) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ArrayList(java.util.ArrayList) ExtSource(cz.metacentrum.perun.core.api.ExtSource) 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 57 with Candidate

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

the class ResourcesManagerEntryIntegrationTest method setUpCandidate.

private Candidate setUpCandidate() {
    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("");
    ExtSource extSource = new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal");
    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) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 58 with Candidate

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

the class MembersManagerEntryIntegrationTest method setUpMember2.

private Member setUpMember2(Vo vo) throws Exception {
    Candidate candidate = setUpCandidate2();
    // candidates.get(0)
    Member member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
    // set first candidate as member of test VO
    assertNotNull("No member created", member);
    usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member));
    Attribute attrEmail = new Attribute(attributesManagerEntry.getAttributeDefinition(sess, AttributesManager.NS_MEMBER_ATTR_DEF + ":mail"));
    attrEmail.setValue("123@456.cz");
    attributesManagerEntry.setAttribute(sess, member, attrEmail);
    User user = usersManagerEntry.getUserByMember(sess, member);
    Attribute attrLogin = new Attribute();
    attrLogin.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attrLogin.setFriendlyName("login-namespace:testMichal2");
    attrLogin.setType(String.class.getName());
    attrLogin = new Attribute(attributesManagerEntry.createAttribute(sess, attrLogin));
    attrLogin.setValue("123456");
    attributesManagerEntry.setAttribute(sess, user, attrLogin);
    return member;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Example 59 with Candidate

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

the class UsersManagerEntryIntegrationTest method setUpCandidateForSpecificUser2.

private Candidate setUpCandidateForSpecificUser2() {
    // Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName("(Service)");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("testingServiceUser02");
    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;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) RichUserExtSource(cz.metacentrum.perun.core.api.RichUserExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 60 with Candidate

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

the class UsersManagerEntryIntegrationTest method setUpSpecificUser1ForUser.

private void setUpSpecificUser1ForUser(Vo vo) throws Exception {
    Candidate candidate = setUpCandidateForSpecificUser1();
    List<User> owners = new ArrayList<>();
    owners.add(user);
    Member serviceMember = perun.getMembersManagerBl().createServiceMember(sess, vo, candidate, owners);
    perun.getMembersManagerBl().validateMember(sess, serviceMember);
    // set first candidate as member of test VO
    assertNotNull("No member created", serviceMember);
    serviceUser1 = usersManager.getUserByMember(sess, serviceMember);
    usersForDeletion.add(serviceUser1);
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) ArrayList(java.util.ArrayList) Member(cz.metacentrum.perun.core.api.Member)

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