use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method removeAllDestinationsWithFacility.
@Test
public void removeAllDestinationsWithFacility() throws Exception {
System.out.println(CLASS_NAME + "removeAllDestinationsWithFacility");
List<Service> services = setUpServices();
facility = setUpFacility();
destination = setUpDestination();
Destination dest1 = perun.getServicesManager().addDestination(sess, services.get(0), facility, destination);
Destination dest2 = perun.getServicesManager().addDestination(sess, services.get(1), facility, destination);
List<Destination> destinations = perun.getServicesManagerBl().getDestinations(sess, facility);
assertTrue("There need to be dest1", destinations.contains(dest1));
assertTrue("There need to be dest2", destinations.contains(dest2));
perun.getServicesManagerBl().removeAllDestinations(sess, facility);
destinations = perun.getServicesManagerBl().getDestinations(sess, facility);
assertTrue("All destinations should be removed", destinations.isEmpty());
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method updateServiceWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void updateServiceWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "updateServiceWhenServiceNotExists");
perun.getServicesManager().updateService(sess, new Service());
// shouldn't find Service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method removeServiceFromServicesPackageWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void removeServiceFromServicesPackageWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeServiceFromServicesPackageWhenServiceNotExists");
service = setUpService();
assertNotNull("unable to create service in DB", service);
servicesPackage = setUpServicesPackage(service);
perun.getServicesManager().removeServiceFromServicesPackage(sess, servicesPackage, new Service());
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntry method getRequiredAttributes.
public List<Attribute> getRequiredAttributes(PerunSession sess, List<Service> services, Resource resource) throws PrivilegeException, InternalErrorException, ResourceNotExistsException, ServiceNotExistsException {
Utils.checkPerunSession(sess);
getPerunBl().getResourcesManagerBl().checkResourceExists(sess, resource);
for (Service s : services) getPerunBl().getServicesManagerBl().checkServiceExists(sess, s);
List<Attribute> attributes = attributesManagerBl.getRequiredAttributes(sess, services, resource);
Iterator<Attribute> attrIter = attributes.iterator();
//Choose to which attributes has the principal access
while (attrIter.hasNext()) {
Attribute attrNext = attrIter.next();
if (!AuthzResolver.isAuthorizedForAttribute(sess, ActionType.READ, attrNext, resource, null))
attrIter.remove();
else
attrNext.setWritable(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, attrNext, resource, null));
}
return attributes;
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getServiceRequiredResourceAttributes.
@Test
public void getServiceRequiredResourceAttributes() throws Exception {
System.out.println(CLASS_NAME + "getServiceRequiredResourceAttributes");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
service = setUpService();
attributes = setUpRequiredAttributes();
perun.getResourcesManager().assignService(sess, resource, service);
Service service2 = setUpService2();
Attribute attr = setUpResourceRequiredAttributeForService(service2);
perun.getResourcesManager().assignService(sess, resource, service2);
List<Service> serviceList = new ArrayList<>();
serviceList.add(service);
List<Attribute> reqAttr = attributesManager.getRequiredAttributes(sess, serviceList, resource);
assertNotNull("unable to get required resource attributes for its services", reqAttr);
assertTrue("should have only 1 req resource attribute", reqAttr.size() == 1);
serviceList.add(service2);
reqAttr = attributesManager.getRequiredAttributes(sess, serviceList, resource);
assertNotNull("unable to get required resource attributes for its services", reqAttr);
assertTrue("should have only 1 req resource attribute", reqAttr.size() == 2);
}
Aggregations