use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method getAssignedRichResources.
@Test
public void getAssignedRichResources() throws Exception {
System.out.println(CLASS_NAME + "getAssignedRichResources");
Vo vo = setUpVo();
Resource resource = setUpResource(vo);
RichResource rresource = new RichResource(resource);
rresource.setVo(perun.getResourcesManager().getVo(sess, resource));
List<RichResource> assignedResources = perun.getFacilitiesManager().getAssignedRichResources(sess, facility);
List<Vo> vos = new ArrayList<Vo>();
for (RichResource rr : assignedResources) {
assertTrue("RichResource must have VO value filled", rr.getVo() != null);
vos.add(rr.getVo());
}
assertTrue("Our VO must be between RichResources VOs", vos.contains(vo));
assertTrue("our facility should have 1 assigned Resource", assignedResources.size() == 1);
assertTrue("our facility should have our Resource assigned", assignedResources.contains(rresource));
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method getBanById.
@Test
public void getBanById() throws Exception {
System.out.println(CLASS_NAME + "getBanById");
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);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
BanOnFacility returnedBan = facilitiesManagerEntry.getBanById(sess, banOnFacility.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method updateBan.
@Test
public void updateBan() throws Exception {
System.out.println(CLASS_NAME + "updateBan");
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);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
banOnFacility.setDescription("New description");
banOnFacility.setValidityTo(new Date(banOnFacility.getValidityTo().getTime() + 1000000));
facilitiesManagerEntry.updateBan(sess, banOnFacility);
BanOnFacility returnedBan = facilitiesManagerEntry.getBanById(sess, banOnFacility.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method setBan.
@Test
public void setBan() throws Exception {
System.out.println(CLASS_NAME + "setBan");
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);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
BanOnFacility returnedBan = facilitiesManagerEntry.setBan(sess, banOnFacility);
banOnFacility.setId(returnedBan.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_group_resource_attribute_def_def_isUnixGroupIntegrationtest method setUpResource.
private Resource setUpResource(Vo vo, Facility facility) throws Exception {
Resource resource = new Resource();
resource.setName("IsUnixGroupTestResource");
resource.setDescription("Testovaci");
resource = perun.getResourcesManagerBl().createResource(sess, resource, vo, facility);
return resource;
}
Aggregations