use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerBlImplUnitTests method setRequiredAttributes_services_f_r_u_m.
@Test
public void setRequiredAttributes_services_f_r_u_m() throws Exception {
System.out.println(CLASS_NAME + "setRequiredAttributes_services_f_r_u_m");
Service s1 = new Service(1, "s1");
Service s2 = new Service(2, "s2");
List<Service> services = Arrays.asList(s1, s2);
Facility facility = new Facility(1, "f");
Resource resource = new Resource(2, "r", "", facility.getId());
User user = new User(3, "a", "b", "", "", "");
Member member = new Member(4, user.getId());
List<Attribute> attributes = new ArrayList<>();
doCallRealMethod().when(attrManagerBlImplMock).setRequiredAttributes(any(), anyList(), any(), any(), any(), any(), anyBoolean());
when(attrManagerBlImplMock.getRequiredAttributes(sessionMock, services, facility, resource, user, member)).thenReturn(attributes);
attrManagerBlImplMock.setRequiredAttributes(sessionMock, services, facility, resource, user, member, true);
verify(attrManagerBlImplMock, times(1)).setRequiredAttributes(eq(sessionMock), eq(facility), eq(resource), eq(user), eq(member), eq(attributes), eq(true));
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class FacilitiesManagerBlImplTest method getAssignedUsersByServiceTest.
@Test
public void getAssignedUsersByServiceTest() throws Exception {
System.out.println("FacilitiesManagerBlImpl.getAssignedUsers(facility, service)");
Service service = new Service(0, "dummy_service");
service = perun.getServicesManagerBl().createService(sess, service);
perun.getResourcesManagerBl().assignService(sess, resource, service);
List<User> users = perun.getFacilitiesManagerBl().getAssignedUsers(sess, facility, service);
Assert.assertEquals(1, users.size());
Assert.assertTrue(users.contains(user));
users = perun.getFacilitiesManagerBl().getAssignedUsers(sess, facility2, service);
Assert.assertTrue(users.isEmpty());
// adding service3 to another facility should work
perun.getResourcesManagerBl().assignService(sess, resource3, service);
users = perun.getFacilitiesManagerBl().getAssignedUsers(sess, facility2, service);
Assert.assertEquals(1, users.size());
Assert.assertTrue(users.contains(user));
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRequiredMemberResourceAttributesFromOneServiceWorkWithUserWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void getRequiredMemberResourceAttributesFromOneServiceWorkWithUserWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "getRequiredMemberResourceAttributesFromOneServiceWorkWithUserWhenServiceNotExists");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
member = setUpMember();
attributesManager.getRequiredAttributes(sess, new Service(), member, resource, true);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
group = setUpGroup();
attributesManager.getRequiredAttributes(sess, new Service(), resource, group);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerImpl method getServicesFromServicesPackage.
@Override
public List<Service> getServicesFromServicesPackage(PerunSession sess, ServicesPackage servicesPackage) {
try {
List<Service> services = new ArrayList<>();
List<Integer> servicesId = jdbc.query("select service_id as id from service_service_packages where package_id=?", Utils.ID_MAPPER, servicesPackage.getId());
for (Integer serviceId : servicesId) {
try {
services.add(getServiceById(sess, serviceId));
} catch (ServiceNotExistsException ex) {
throw new InternalErrorException(ex);
}
}
return services;
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
Aggregations