use of cz.metacentrum.perun.core.api.MemberWithSponsors in project perun by CESNET.
the class VosManagerEntryIntegrationTest method convertSponsoredUsersWithNewSponsor.
@Test
public void convertSponsoredUsersWithNewSponsor() throws Exception {
System.out.println(CLASS_NAME + "convertSponsoredUsersWithNewSponsor");
myVo = vosManagerEntry.createVo(sess, myVo);
User user = new User(-1, "Sponsored", "User", "", "", "");
user.setSponsoredUser(true);
User originalSponsor = new User(-1, "Sponsor 1", "", "", "", "");
User newSponsor = new User(-1, "Sponsor 2", "", "", "", "");
user = perun.getUsersManagerBl().createUser(sess, user);
originalSponsor = perun.getUsersManagerBl().createUser(sess, originalSponsor);
newSponsor = perun.getUsersManagerBl().createUser(sess, newSponsor);
perun.getUsersManagerBl().addSpecificUserOwner(sess, originalSponsor, user);
Member member = perun.getMembersManagerBl().createMember(sess, myVo, user);
perun.getVosManager().convertSponsoredUsersWithNewSponsor(sess, myVo, newSponsor);
List<MemberWithSponsors> sponsoredMembersAndTheirSponsors = perun.getMembersManager().getSponsoredMembersAndTheirSponsors(sess, myVo, Collections.emptyList());
assertThat(sponsoredMembersAndTheirSponsors).hasSize(1);
Member sponsoredMember = sponsoredMembersAndTheirSponsors.get(0).getMember();
List<Sponsor> sponsors = sponsoredMembersAndTheirSponsors.get(0).getSponsors();
assertThat(sponsoredMember).isEqualTo(member);
assertThat(sponsors).contains(new Sponsor(new RichUser(newSponsor, Collections.emptyList())));
}
Aggregations