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