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));
}
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;
}
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;
}
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;
}
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);
}
Aggregations