use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method getServiceByName.
@Test
public void getServiceByName() throws Exception {
System.out.println(CLASS_NAME + "getServiceByName");
service = setUpService();
assertNotNull("unable to create service", service);
Service returnedService = perun.getServicesManager().getServiceByName(sess, service.getName());
assertEquals("cannot get service by Name", returnedService, service);
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method addDestinationForMoreThanOneService.
@Test
public void addDestinationForMoreThanOneService() throws Exception {
System.out.println(CLASS_NAME + "addDestinationForMoreThanOneService");
List<Service> services = setUpServices();
facility = setUpFacility();
destination = setUpDestination();
perun.getServicesManager().addDestination(sess, services, facility, destination);
List<RichDestination> destinations = perun.getServicesManager().getRichDestinations(sess, facility, services.get(0));
destinations.addAll(perun.getServicesManager().getRichDestinations(sess, facility, services.get(1)));
assertTrue("service should have 1 destination", destinations.size() == 2);
for (RichDestination rd : destinations) {
assertTrue("destination in richDestination need to be our destination", rd.getDestination().equals(destination.getDestination()));
assertTrue("type of destination need to be our type of destination", rd.getType().equals(destination.getType()));
assertTrue("richDestination has service from our list of services", services.contains(rd.getService()));
}
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method removeRequiredAttributesWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void removeRequiredAttributesWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeRequiredAttributesWhenServiceNotExists");
List<AttributeDefinition> attributes = setUpRequiredAttribute();
perun.getServicesManager().removeRequiredAttributes(sess, new Service(), attributes);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method getDestinationsWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void getDestinationsWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "getDestinationsWhenServiceNotExists");
facility = setUpFacility();
perun.getServicesManager().getDestinations(sess, new Service(), facility);
// shouldn't find Service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityService.
@Test
public void getUsersPage_facilityService() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityService");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
Facility facility = new Facility();
facility.setName("UsersManagerTestFacility");
facility = perun.getFacilitiesManager().createFacility(sess, facility);
Resource r = new Resource(0, "name", "description", facility.getId());
r = perun.getResourcesManager().createResource(sess, r, vo, facility);
Vo newVo = new Vo(2, "UserManagerTestV2o", "UMTestVo2");
Vo returnedVo = perun.getVosManager().createVo(sess, newVo);
Resource r2 = new Resource(1, "name1", "description1", facility.getId());
r2 = perun.getResourcesManager().createResource(sess, r2, returnedVo, facility);
Service service = new Service(0, "dummy_service");
service = perun.getServicesManagerBl().createService(sess, service);
perun.getResourcesManagerBl().assignService(sess, r, service);
perun.getResourcesManagerBl().assignService(sess, r2, service);
Member member = perun.getMembersManagerBl().createMember(sess, vo, user);
Member member2 = perun.getMembersManagerBl().createMember(sess, returnedVo, user2);
Group g1 = setUpGroup(vo, member, "group1");
Group g2 = setUpGroup(returnedVo, member2, "group2");
perun.getResourcesManager().assignGroupToResource(sess, g1, r, false, false, false);
perun.getResourcesManager().assignGroupToResource(sess, g2, r2, false, false, false);
UsersPageQuery query = new UsersPageQuery(3, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "", facility.getId(), null, service.getId(), null);
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(2, users.getData().size());
assertEquals(2, users.getTotalCount());
assertTrue(users.getData().containsAll(usersManager.getRichUsersByIds(sess, List.of(user.getId(), user2.getId()))));
}
Aggregations