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