Search in sources :

Example 21 with BanOnFacility

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

the class FacilitiesManagerEntryIntegrationTest method removeBan.

@Test
public void removeBan() throws Exception {
    System.out.println(CLASS_NAME + "removeBan");
    Vo vo = setUpVo();
    Resource resource = setUpResource(vo);
    Member member = setUpMember(vo);
    User user = perun.getUsersManagerBl().getUserByMember(sess, member);
    Group group = setUpGroup(vo, member);
    perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource, false, false, false);
    BanOnFacility banOnFacility = new BanOnFacility();
    banOnFacility.setUserId(user.getId());
    banOnFacility.setFacilityId(facility.getId());
    banOnFacility.setDescription("Popisek");
    banOnFacility.setValidityTo(new Date());
    banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
    List<BanOnFacility> bansOnFacility = facilitiesManagerEntry.getBansForFacility(sess, banOnFacility.getFacilityId());
    assertTrue(bansOnFacility.size() == 1);
    perun.getFacilitiesManagerBl().removeBan(sess, banOnFacility.getUserId(), banOnFacility.getFacilityId());
    bansOnFacility = facilitiesManagerEntry.getBansForFacility(sess, banOnFacility.getFacilityId());
    assertTrue(bansOnFacility.isEmpty());
}
Also used : Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Resource(cz.metacentrum.perun.core.api.Resource) RichResource(cz.metacentrum.perun.core.api.RichResource) Vo(cz.metacentrum.perun.core.api.Vo) Member(cz.metacentrum.perun.core.api.Member) Date(java.util.Date) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 22 with BanOnFacility

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

the class FacilitiesManagerEntryIntegrationTest method getBansForUser.

@Test
public void getBansForUser() throws Exception {
    System.out.println(CLASS_NAME + "getBansForUser");
    Vo vo = setUpVo();
    Resource resource = setUpResource(vo);
    Member member = setUpMember(vo);
    User user = perun.getUsersManagerBl().getUserByMember(sess, member);
    Group group = setUpGroup(vo, member);
    perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource, false, false, false);
    BanOnFacility banOnFacility = new BanOnFacility();
    banOnFacility.setUserId(user.getId());
    banOnFacility.setFacilityId(facility.getId());
    banOnFacility.setDescription("Popisek");
    banOnFacility.setValidityTo(new Date());
    banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
    List<BanOnFacility> returnedBans = facilitiesManagerEntry.getBansForUser(sess, banOnFacility.getUserId());
    assertEquals(banOnFacility, returnedBans.get(0));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Resource(cz.metacentrum.perun.core.api.Resource) RichResource(cz.metacentrum.perun.core.api.RichResource) Vo(cz.metacentrum.perun.core.api.Vo) Member(cz.metacentrum.perun.core.api.Member) Date(java.util.Date) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)22 User (cz.metacentrum.perun.core.api.User)16 RichUser (cz.metacentrum.perun.core.api.RichUser)15 Member (cz.metacentrum.perun.core.api.Member)12 Resource (cz.metacentrum.perun.core.api.Resource)12 Group (cz.metacentrum.perun.core.api.Group)11 RichResource (cz.metacentrum.perun.core.api.RichResource)11 Vo (cz.metacentrum.perun.core.api.Vo)11 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)10 Date (java.util.Date)10 Test (org.junit.Test)10 Facility (cz.metacentrum.perun.core.api.Facility)8 EnrichedFacility (cz.metacentrum.perun.core.api.EnrichedFacility)7 RichFacility (cz.metacentrum.perun.core.api.RichFacility)7 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)6 BanNotExistsException (cz.metacentrum.perun.core.api.exceptions.BanNotExistsException)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)3 RelationExistsException (cz.metacentrum.perun.core.api.exceptions.RelationExistsException)3 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)3 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)3