Search in sources :

Example 96 with Service

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);
}
Also used : Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 97 with 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()));
    }
}
Also used : RichDestination(cz.metacentrum.perun.core.api.RichDestination) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 98 with Service

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
}
Also used : AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 99 with 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
}
Also used : Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 100 with 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()))));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) UsersPageQuery(cz.metacentrum.perun.core.api.UsersPageQuery) RichUser(cz.metacentrum.perun.core.api.RichUser) Resource(cz.metacentrum.perun.core.api.Resource) Vo(cz.metacentrum.perun.core.api.Vo) Service(cz.metacentrum.perun.core.api.Service) Facility(cz.metacentrum.perun.core.api.Facility) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

Service (cz.metacentrum.perun.core.api.Service)115 Test (org.junit.Test)64 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)55 Facility (cz.metacentrum.perun.core.api.Facility)31 ArrayList (java.util.ArrayList)26 Resource (cz.metacentrum.perun.core.api.Resource)22 Destination (cz.metacentrum.perun.core.api.Destination)20 Member (cz.metacentrum.perun.core.api.Member)17 User (cz.metacentrum.perun.core.api.User)17 Group (cz.metacentrum.perun.core.api.Group)15 Vo (cz.metacentrum.perun.core.api.Vo)13 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)13 Attribute (cz.metacentrum.perun.core.api.Attribute)11 RichUser (cz.metacentrum.perun.core.api.RichUser)11 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)11 Task (cz.metacentrum.perun.taskslib.model.Task)10 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)8 PerunClient (cz.metacentrum.perun.core.api.PerunClient)8 PerunPrincipal (cz.metacentrum.perun.core.api.PerunPrincipal)8 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)8