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