Search in sources :

Example 51 with Resource

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

the class AttributesManagerEntryIntegrationTest method getResourceRequiredMemberResourceAttributesWhenSecondResourceNotExists.

@Test(expected = ResourceNotExistsException.class)
public void getResourceRequiredMemberResourceAttributesWhenSecondResourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "getResourceRequiredMemberResourceAttributesWhenSecondResourceNotExists");
    vo = setUpVo();
    member = setUpMember();
    facility = setUpFacility();
    resource = setUpResource();
    attributesManager.getResourceRequiredAttributes(sess, resource, new Resource(), member);
// shouldn't find resource
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 52 with Resource

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

the class AttributesManagerEntryIntegrationTest method getResourceMemberAttributesForUserWhenResourceNotExists.

@Test(expected = ResourceNotExistsException.class)
public void getResourceMemberAttributesForUserWhenResourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "getResourceMemberAttributesForUserWhenResourceNotExists");
    vo = setUpVo();
    member = setUpMember();
    attributesManager.getAttributes(sess, new Resource(), member, true);
// shouldn't find resource
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 53 with Resource

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

the class AttributesManagerEntryIntegrationTest method removeMemberResourceAttributesWhenResourceNotExists.

@Test(expected = ResourceNotExistsException.class)
public void removeMemberResourceAttributesWhenResourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "removeMemberResourceAttributesWhenResourceNotExists");
    attributes = setUpMemberResourceAttribute();
    vo = setUpVo();
    member = setUpMember();
    attributesManager.removeAttributes(sess, new Resource(), member, attributes);
// shouldn't find resource
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 54 with Resource

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

the class AttributesManagerEntryIntegrationTest method getResourceRequiredMemberGroupAttributesWhenResourceNotExists.

@Test(expected = ResourceNotExistsException.class)
public void getResourceRequiredMemberGroupAttributesWhenResourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "getResourceRequiredMemberGroupAttributesWhenResourceNotExists");
    vo = setUpVo();
    group = setUpGroup();
    member = setUpMember();
    facility = setUpFacility();
    resource = setUpResource();
    attributesManager.getResourceRequiredAttributes(sess, new Resource(), member, group);
// shouldn't find resource
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 55 with Resource

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

the class FacilitiesManagerEntryIntegrationTest method getAllowedMembers.

@Test
public void getAllowedMembers() throws Exception {
    System.out.println(CLASS_NAME + "getAllowedMembers");
    // Test that new method returns same data as old behavior
    Vo vo2 = new Vo(0, "facilityTestVo002", "facilityTestVo002");
    vo2 = perun.getVosManagerBl().createVo(sess, vo2);
    Member member11 = setUpMember(vo);
    Member member12 = setUpMember(vo);
    Member member21 = setUpMember(vo2);
    Member member22 = setUpMember(vo2);
    Resource resource1 = setUpResource(vo);
    Resource resource2 = setUpResource(vo2);
    Group group1 = setUpGroup(vo, member11);
    Group group2 = setUpGroup(vo2, member21);
    // make them not-allowed
    perun.getMembersManager().setStatus(sess, member12, Status.INVALID);
    perun.getMembersManager().setStatus(sess, member22, Status.DISABLED);
    perun.getGroupsManager().addMember(sess, group1, member12);
    perun.getGroupsManager().addMember(sess, group2, member22);
    perun.getResourcesManager().assignGroupToResource(sess, group1, resource1);
    perun.getResourcesManager().assignGroupToResource(sess, group2, resource2);
    // test new way - single select
    List<Member> members = perun.getFacilitiesManagerBl().getAllowedMembers(sess, facility);
    Assert.notNull(members);
    assertTrue(members.size() == 2);
    assertTrue(members.contains(member11));
    assertTrue(members.contains(member21));
    assertTrue(!members.contains(member12));
    assertTrue(!members.contains(member22));
    // test old way - iterate over resources
    List<Resource> resources = perun.getFacilitiesManager().getAssignedResources(sess, facility);
    List<Member> oldMembers = new ArrayList<Member>();
    for (Resource r : resources) {
        oldMembers.addAll(perun.getResourcesManager().getAllowedMembers(sess, r));
    }
    Assert.notNull(oldMembers);
    assertTrue(oldMembers.contains(member11));
    assertTrue(oldMembers.contains(member21));
    assertTrue(!oldMembers.contains(member12));
    assertTrue(!oldMembers.contains(member22));
    assertEquals(new HashSet<>(members), new HashSet<>(members));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) 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) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

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