Search in sources :

Example 66 with Candidate

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

the class MembersManagerEntryIntegrationTest method setUpCandidate.

private Candidate setUpCandidate() {
    String userFirstName = "FirstTest";
    String userLastName = "LastTest";
    String extLogin = "ExtLoginTest";
    // Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName(userFirstName);
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName(userLastName);
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    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 67 with Candidate

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

the class MembersManagerEntryIntegrationTest method setUpSponsor2.

private Member setUpSponsor2(Vo vo) throws Exception {
    Candidate candidate = setUpCandidateSponsor2();
    // 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("jan@sponsor.cz");
    attributesManagerEntry.setAttribute(sess, member, attrEmail);
    return member;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) Attribute(cz.metacentrum.perun.core.api.Attribute) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Example 68 with Candidate

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

the class MembersManagerEntryIntegrationTest method createServiceMemberFromCandidateInGroup.

@Test
public void createServiceMemberFromCandidateInGroup() throws Exception {
    System.out.println(CLASS_NAME + "createServiceMember");
    // 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", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), extLogin);
    candidate.setUserExtSource(ues);
    candidate.setAttributes(new HashMap<>());
    List<User> specificUserOwners = new ArrayList<>();
    specificUserOwners.add(perun.getUsersManagerBl().getUserByMember(sess, createdMember));
    Member member = perun.getMembersManager().createSpecificMember(sess, createdVo, candidate, specificUserOwners, SpecificUserType.SERVICE, 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) User(cz.metacentrum.perun.core.api.User) 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 69 with Candidate

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

the class MembersManagerEntryIntegrationTest method setUpCandidate2.

private Candidate setUpCandidate2() {
    String userFirstName = "Abcd";
    String userLastName = "Efgh";
    String extLogin = "Ijkl";
    // Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName(userFirstName);
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName(userLastName);
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    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 70 with Candidate

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

the class MembersManagerEntryIntegrationTest method setUpSponsor.

private Member setUpSponsor(Vo vo) throws Exception {
    Candidate candidate = setUpCandidateSponsor();
    // 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("jan@sponsor.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:dummy");
    attrLogin.setType(String.class.getName());
    attrLogin = new Attribute(attributesManagerEntry.createAttribute(sess, attrLogin));
    attrLogin.setValue("111111");
    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)

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