Search in sources :

Example 6 with MemberWithSponsors

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())));
}
Also used : RichUser(cz.metacentrum.perun.core.api.RichUser) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) Sponsor(cz.metacentrum.perun.core.api.Sponsor) MemberWithSponsors(cz.metacentrum.perun.core.api.MemberWithSponsors) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

Member (cz.metacentrum.perun.core.api.Member)6 MemberWithSponsors (cz.metacentrum.perun.core.api.MemberWithSponsors)6 User (cz.metacentrum.perun.core.api.User)6 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)5 Test (org.junit.Test)5 RichMember (cz.metacentrum.perun.core.api.RichMember)4 Sponsor (cz.metacentrum.perun.core.api.Sponsor)4 Group (cz.metacentrum.perun.core.api.Group)3 ArrayList (java.util.ArrayList)3 RichUser (cz.metacentrum.perun.core.api.RichUser)2 Attribute (cz.metacentrum.perun.core.api.Attribute)1 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 AuthzResolver (cz.metacentrum.perun.core.api.AuthzResolver)1 Candidate (cz.metacentrum.perun.core.api.Candidate)1 ExtSource (cz.metacentrum.perun.core.api.ExtSource)1 MembersManager (cz.metacentrum.perun.core.api.MembersManager)1 MembersPageQuery (cz.metacentrum.perun.core.api.MembersPageQuery)1 NamespaceRules (cz.metacentrum.perun.core.api.NamespaceRules)1 Paginated (cz.metacentrum.perun.core.api.Paginated)1 PerunSession (cz.metacentrum.perun.core.api.PerunSession)1