Search in sources :

Example 1 with EnrichedFacility

use of cz.metacentrum.perun.core.api.EnrichedFacility in project perun by CESNET.

the class FacilitiesManagerEntryIntegrationTest method getEnrichedFacilities.

@Test
public void getEnrichedFacilities() throws Exception {
    System.out.println(CLASS_NAME + "getEnrichedFacilities");
    Service serv = new Service();
    serv.setName("TestovaciSluzba");
    perun.getServicesManager().createService(sess, serv);
    Destination dest = new Destination();
    dest.setType("service-specific");
    dest.setDestination("TestovaciDestinace");
    perun.getServicesManager().addDestination(sess, serv, facility, dest);
    facilitiesManagerEntry.addHosts(sess, hosts, facility);
    // set this host for deletion - host is created after adding to facility !!
    hostsForDeletion.add(hosts.get(0));
    EnrichedFacility expectedEnrichedFacility = new EnrichedFacility(facility, Collections.singletonList(owner), Collections.singletonList(dest), hosts);
    List<EnrichedFacility> enrichedFacilities = perun.getFacilitiesManager().getEnrichedFacilities(sess);
    assertTrue("The expected enriched facility should be returned", enrichedFacilities.contains(expectedEnrichedFacility));
    EnrichedFacility actualEnrichedFacility = enrichedFacilities.get(enrichedFacilities.indexOf(expectedEnrichedFacility));
    assertEquals("Returned enrichedFacility should have the same number of owners", expectedEnrichedFacility.getOwners().size(), actualEnrichedFacility.getOwners().size());
    assertEquals("Returned enrichedFacility should have the same number of destinations", expectedEnrichedFacility.getDestinations().size(), actualEnrichedFacility.getDestinations().size());
    assertEquals("Returned enrichedFacility should have the same number of hosts", expectedEnrichedFacility.getHosts().size(), actualEnrichedFacility.getHosts().size());
    assertTrue("Returned enrichedFacility should have the same owners", expectedEnrichedFacility.getOwners().containsAll(actualEnrichedFacility.getOwners()));
    assertTrue("Returned enrichedFacility should have the same destinations", expectedEnrichedFacility.getDestinations().containsAll(actualEnrichedFacility.getDestinations()));
    assertTrue("Returned enrichedFacility should have the same hosts", expectedEnrichedFacility.getHosts().containsAll(actualEnrichedFacility.getHosts()));
}
Also used : Destination(cz.metacentrum.perun.core.api.Destination) EnrichedFacility(cz.metacentrum.perun.core.api.EnrichedFacility) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)1 Destination (cz.metacentrum.perun.core.api.Destination)1 EnrichedFacility (cz.metacentrum.perun.core.api.EnrichedFacility)1 Service (cz.metacentrum.perun.core.api.Service)1 Test (org.junit.Test)1