Search in sources :

Example 36 with Resource

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));
}
Also used : RichResource(cz.metacentrum.perun.core.api.RichResource) Resource(cz.metacentrum.perun.core.api.Resource) RichResource(cz.metacentrum.perun.core.api.RichResource) ArrayList(java.util.ArrayList) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 37 with Resource

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);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) 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 38 with Resource

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);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) 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 39 with Resource

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);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) 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 40 with Resource

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;
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource)

Aggregations

Resource (cz.metacentrum.perun.core.api.Resource)176 Test (org.junit.Test)110 Attribute (cz.metacentrum.perun.core.api.Attribute)82 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)79 Facility (cz.metacentrum.perun.core.api.Facility)56 User (cz.metacentrum.perun.core.api.User)55 Group (cz.metacentrum.perun.core.api.Group)49 ArrayList (java.util.ArrayList)41 Vo (cz.metacentrum.perun.core.api.Vo)31 Member (cz.metacentrum.perun.core.api.Member)29 PerunSession (cz.metacentrum.perun.core.api.PerunSession)29 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)26 RichResource (cz.metacentrum.perun.core.api.RichResource)25 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)20 RichUser (cz.metacentrum.perun.core.api.RichUser)18 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)18 ContactGroup (cz.metacentrum.perun.core.api.ContactGroup)17 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)17 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)15 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)14