Search in sources :

Example 16 with DiscreteResource

use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.

the class GenericDiscreteResourcesTest method testIfDifferenceIsNotEmpty.

@Test
public void testIfDifferenceIsNotEmpty() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1, res2));
    DiscreteResources other = GenericDiscreteResources.of(ImmutableSet.of(res1));
    DiscreteResources expected = GenericDiscreteResources.of(ImmutableSet.of(res2));
    assertThat(sut.difference(other), is(expected));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 17 with DiscreteResource

use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.

the class GenericDiscreteResourcesTest method testIfDifferenceIsEmpty.

@Test
public void testIfDifferenceIsEmpty() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1, res2));
    DiscreteResources other = GenericDiscreteResources.of(ImmutableSet.of(res1, res2));
    DiscreteResources expected = GenericDiscreteResources.of(ImmutableSet.of());
    assertThat(sut.difference(other), is(expected));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 18 with DiscreteResource

use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.

the class GenericDiscreteResourcesTest method testIfResourceIsNotContained.

@Test
public void testIfResourceIsNotContained() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1));
    assertThat(sut.containsAny(ImmutableSet.of(res2)), is(false));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 19 with DiscreteResource

use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.

the class GenericDiscreteResourcesTest method testIfResourceIsContained.

@Test
public void testIfResourceIsContained() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1));
    assertThat(sut.containsAny(ImmutableSet.of(res1)), is(true));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 20 with DiscreteResource

use of org.onosproject.net.resource.DiscreteResource in project onos by opennetworkinglab.

the class GenericDiscreteResourcesTest method testDifferenceFromEmpty.

@Test
public void testDifferenceFromEmpty() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1));
    DiscreteResources other = GenericDiscreteResources.of(ImmutableSet.of());
    DiscreteResources expected = GenericDiscreteResources.of(ImmutableSet.of(res1));
    assertThat(sut.difference(other), is(expected));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Aggregations

DiscreteResource (org.onosproject.net.resource.DiscreteResource)47 Test (org.junit.Test)38 Resource (org.onosproject.net.resource.Resource)6 ImmutableSet (com.google.common.collect.ImmutableSet)4 Set (java.util.Set)4 ContinuousResource (org.onosproject.net.resource.ContinuousResource)4 Resources (org.onosproject.net.resource.Resources)4 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 Optional (java.util.Optional)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 PortNumber (org.onosproject.net.PortNumber)3 ResourceConsumerId (org.onosproject.net.resource.ResourceConsumerId)3 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 VlanId (org.onlab.packet.VlanId)2 DeviceId (org.onosproject.net.DeviceId)2