Search in sources :

Example 76 with Candidate

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

the class ResourcesManagerBlImplTest method setUp.

@Before
public void setUp() throws Exception {
    candidate = new Candidate();
    candidate.setFirstName("some");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("testingUser");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    ues = new UserExtSource(extSource, "extLogin");
    candidate.setUserExtSource(ues);
    candidate.setAttributes(new HashMap<>());
    sess = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
    vo = new Vo(0, "ResourcesBlImplTestVo", "ResMgrBlImplTestVo");
    vo = perun.getVosManagerBl().createVo(sess, vo);
    member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
    group = new Group("testGroup", "testGroup");
    group = perun.getGroupsManagerBl().createGroup(sess, vo, group);
    perun.getGroupsManagerBl().addMember(sess, group, member);
    facility = new Facility(0, "testFac");
    facility = perun.getFacilitiesManagerBl().createFacility(sess, facility);
    resource = new Resource(0, "testRes", null, facility.getId(), vo.getId());
    resource = perun.getResourcesManagerBl().createResource(sess, resource, vo, facility);
    perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource, false, false, false);
    // second branch
    vo2 = new Vo(0, "FacilitiesManagerBlImplTestVo2", "FacMgrBlImplTestVo2");
    vo2 = perun.getVosManagerBl().createVo(sess, vo2);
    member2 = perun.getMembersManagerBl().createMemberSync(sess, vo2, candidate);
    group2 = new Group("testGroup", "testGroup");
    group2 = perun.getGroupsManagerBl().createGroup(sess, vo2, group2);
    perun.getGroupsManagerBl().addMember(sess, group2, member2);
    resource2 = new Resource(0, "testRes2", null, facility.getId(), vo2.getId());
    resource2 = perun.getResourcesManagerBl().createResource(sess, resource2, vo2, facility);
    // third branch
    facility2 = new Facility(0, "testFac2");
    facility2 = perun.getFacilitiesManagerBl().createFacility(sess, facility2);
    resource3 = new Resource(0, "testRes3", null, facility2.getId(), vo2.getId());
    resource3 = perun.getResourcesManagerBl().createResource(sess, resource3, vo2, facility2);
    perun.getResourcesManagerBl().assignGroupToResources(sess, group2, Arrays.asList(resource2, resource3), false, false, false);
    user = perun.getUsersManagerBl().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) PerunClient(cz.metacentrum.perun.core.api.PerunClient) Resource(cz.metacentrum.perun.core.api.Resource) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) Vo(cz.metacentrum.perun.core.api.Vo) Facility(cz.metacentrum.perun.core.api.Facility) Before(org.junit.Before)

Example 77 with Candidate

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

the class urn_perun_group_resource_attribute_def_def_isUnixGroupIntegrationtest method setUpCandidate.

private Candidate setUpCandidate() {
    // 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 78 with Candidate

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

the class AttributesManagerEntryIntegrationTest 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 79 with Candidate

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

the class UsersManagerEntryIntegrationTest method setUpCandidateForSponsoredUser.

private Candidate setUpCandidateForSponsoredUser() {
    Candidate candidate = new Candidate();
    candidate.setFirstName("Sponsored");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("User01");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    candidate.setServiceUser(false);
    candidate.setSponsoredUser(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 80 with Candidate

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

the class VosManagerEntryIntegrationTest method createMemberFromExtSource.

// private methods ------------------------------------------------------------------
private Member createMemberFromExtSource(final Vo createdVo) throws Exception {
    // This is obsolete approach which is dependent on extSource, remove these lines in future...
    // addExtSourceDelegate(createdVo);
    // final List<Candidate> candidates = vosManagerEntry.findCandidates(sess,
    // createdVo, "kouril", 1);
    final Candidate candidate = prepareCandidate();
    final MembersManager membersManagerEntry = perun.getMembersManager();
    // candidates.get(0));
    final Member member = perun.getMembersManagerBl().createMemberSync(sess, createdVo, 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) MemberCandidate(cz.metacentrum.perun.core.api.MemberCandidate) MembersManager(cz.metacentrum.perun.core.api.MembersManager) 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