use of cz.metacentrum.perun.audit.events.ResourceManagerEvents.ServiceAssignedToResource in project perun by CESNET.
the class ResourcesManagerBlImpl method assignServices.
@Override
public void assignServices(PerunSession sess, Resource resource, List<Service> services) throws ServiceAlreadyAssignedException, WrongAttributeValueException, WrongReferenceAttributeValueException {
for (Service service : services) {
getResourcesManagerImpl().assignService(sess, resource, service);
getPerunBl().getAuditer().log(sess, new ServiceAssignedToResource(service, resource));
}
boolean requiresAttributes = services.stream().anyMatch(s -> !getPerunBl().getAttributesManagerBl().getRequiredAttributesDefinition(sess, s).isEmpty());
if (!requiresAttributes) {
// there are new no attributes to check or add
return;
}
try {
fillAndSetRequiredAttributesForGroups(sess, services, resource);
checkSemanticsOfFacilityAndResourceRequiredAttributes(sess, resource);
updateAllRequiredAttributesForAllowedMembers(sess, resource, services);
} catch (WrongAttributeAssignmentException | GroupResourceMismatchException | MemberResourceMismatchException | AttributeNotExistsException e) {
throw new ConsistencyErrorException(e);
}
}
use of cz.metacentrum.perun.audit.events.ResourceManagerEvents.ServiceAssignedToResource in project perun by CESNET.
the class ResourcesManagerBlImplUnitTest method assignServices.
@Test
public void assignServices() throws Exception {
System.out.println(CLASS_NAME + "assignServices");
Resource resource = new Resource(1, "r1", "", -1);
Service s1 = new Service(1, "s1");
Service s2 = new Service(2, "s2");
List<Service> services = Arrays.asList(s1, s2);
doCallRealMethod().when(resourcesManagerBlMock).assignServices(sessionMock, resource, services);
resourcesManagerBlMock.assignServices(sessionMock, resource, services);
for (Service service : services) {
verify(resourcesManagerImplMock, times(1)).assignService(sessionMock, resource, service);
verify(auditerMock, times(1)).log(sessionMock, new ServiceAssignedToResource(service, resource));
}
}
Aggregations