use of cz.metacentrum.perun.core.api.ResourceTag in project perun by CESNET.
the class ResourcesManagerBlImpl method removeResourceTagFromResource.
@Override
public void removeResourceTagFromResource(PerunSession perunSession, ResourceTag resourceTag, Resource resource) throws ResourceTagNotAssignedException {
List<ResourceTag> allResourceTags = this.getAllResourcesTagsForResource(perunSession, resource);
if (!allResourceTags.contains(resourceTag))
throw new ResourceTagNotAssignedException(resourceTag);
getResourcesManagerImpl().removeResourceTagFromResource(perunSession, resourceTag, resource);
}
use of cz.metacentrum.perun.core.api.ResourceTag in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method getAllResourcesByResourceTag.
@Test
public void getAllResourcesByResourceTag() throws Exception {
System.out.println(CLASS_NAME + "getAllResourcesByResourceTag");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
ResourceTag tag = setUpResourceTag();
resourcesManager.assignResourceTagToResource(sess, tag, resource);
List<Resource> resources = perun.getResourcesManager().getAllResourcesByResourceTag(sess, tag);
assertTrue("Resource with tag is not returned by same tag", resources.contains(resource));
}
use of cz.metacentrum.perun.core.api.ResourceTag in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method copyResourceWithEverythingFilled.
@Test
public void copyResourceWithEverythingFilled() throws Exception {
System.out.println(CLASS_NAME + "copyResourceWithEverythingFilled");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
resource.setVoId(vo.getId());
resource.setFacilityId(facility.getId());
assertNotNull("resource", resource);
// Setup of groups,services and tags
Member member = setUpMember(vo);
group = setUpGroup(vo, member);
service = setUpService();
ResourceTag resTag = setUpResourceTag();
resourcesManager.assignService(sess, resource, service);
resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
resourcesManager.assignResourceTagToResource(sess, resTag, resource);
Resource destinationResource = new Resource();
destinationResource.setName("DestinationResource");
destinationResource.setDescription("DestinationResource");
destinationResource.setVoId(vo.getId());
destinationResource.setFacilityId(facility.getId());
// Setup of resource-member attribute
AttributeDefinition resourceMemberAttrDef = new AttributeDefinition();
resourceMemberAttrDef.setNamespace(AttributesManager.NS_MEMBER_RESOURCE_ATTR_DEF);
resourceMemberAttrDef.setFriendlyName("memberResourceAttribute");
resourceMemberAttrDef.setType(Integer.class.getName());
resourceMemberAttrDef = perun.getAttributesManagerBl().createAttribute(sess, resourceMemberAttrDef);
Attribute resourceMemberAttr = perun.getAttributesManagerBl().getAttribute(sess, member, resource, resourceMemberAttrDef.getName());
resourceMemberAttr.setValue(1);
perun.getAttributesManagerBl().setAttribute(sess, member, resource, resourceMemberAttr);
resourcesManager.copyResource(sess, resource, destinationResource, true);
Resource createdResource = resourcesManager.getResourceByName(sess, vo, facility, destinationResource.getName());
assertNotNull("Resource was not created.", createdResource);
// group, service and resource tags copy check
assertFalse("Group assigned to original resource not copied to destination resource.", resourcesManager.getAssignedGroups(sess, createdResource).isEmpty());
assertFalse("Service not copied to destination resource.", resourcesManager.getAssignedServices(sess, createdResource).isEmpty());
assertFalse("Resource tag not created for destination resource.", resourcesManager.getAllResourcesTagsForResource(sess, createdResource).isEmpty());
// resource-member attributes check
List<Attribute> resMembAttrs = perun.getAttributesManagerBl().getAttributes(sess, member, createdResource);
assertFalse("Created resource does not contain any resource-member attributes.", resMembAttrs.isEmpty());
assertTrue("Created resource does not contain template resource-member attribute (or copied value of attribute is wrong).", resMembAttrs.contains(resourceMemberAttr));
}
use of cz.metacentrum.perun.core.api.ResourceTag in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method getResourceAssignmentsContainsTags.
@Test
public void getResourceAssignmentsContainsTags() throws Exception {
System.out.println(CLASS_NAME + "getResourceAssignmentsContainsTags");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
resource = setUpResource();
ResourceTag resourceTag = new ResourceTag(1, "This is a tag", vo.getId());
resourcesManager.createResourceTag(sess, resourceTag, vo);
resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
resourcesManager.assignResourceTagToResource(sess, resourceTag, resource);
List<AssignedResource> resources = resourcesManager.getResourceAssignments(sess, group, null);
assertThat(resources.get(0).getResourceTags()).containsOnly(resourceTag);
}
use of cz.metacentrum.perun.core.api.ResourceTag in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method getAllResourcesTagsForVo.
@Test
public void getAllResourcesTagsForVo() throws Exception {
System.out.println(CLASS_NAME + "getAllResourcesTagsForVo");
vo = setUpVo();
ResourceTag tag = setUpResourceTag();
List<ResourceTag> tags = perun.getResourcesManager().getAllResourcesTagsForVo(sess, vo);
assertTrue("Created tag is not returned from VO", tags.contains(tag));
}
Aggregations