Search in sources :

Example 6 with DiscreteResource

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

the class EncodableDiscreteResourcesTest method testNotEmpty.

@Test
public void testNotEmpty() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();
    DiscreteResources sut = EncodableDiscreteResources.of(ImmutableSet.of(res1));
    assertThat(sut.isEmpty(), is(false));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 7 with DiscreteResource

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

the class EncodableDiscreteResourcesTest method testIfResourceIsFound.

@Test
public void testIfResourceIsFound() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();
    DiscreteResources sut = EncodableDiscreteResources.of(ImmutableSet.of(res1));
    assertThat(sut.lookup(res1.id()), is(Optional.of(res1)));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 8 with DiscreteResource

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

the class EncodableDiscreteResourcesTest method testIfResourceIsContained.

@Test
public void testIfResourceIsContained() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();
    DiscreteResources sut = EncodableDiscreteResources.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 9 with DiscreteResource

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

the class EncodableDiscreteResourcesTest method testValues.

@Test
public void testValues() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(2)).resource();
    DiscreteResources sut = EncodableDiscreteResources.of(ImmutableSet.of(res1, res2));
    assertThat(sut.values(), is(ImmutableSet.of(res1, res2)));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 10 with DiscreteResource

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

the class EncodableDiscreteResourcesTest method testIfDifferenceIsNotChanged.

@Test
public void testIfDifferenceIsNotChanged() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(2)).resource();
    DiscreteResources sut = EncodableDiscreteResources.of(ImmutableSet.of(res1));
    DiscreteResources other = EncodableDiscreteResources.of(ImmutableSet.of(res2));
    DiscreteResources expected = EncodableDiscreteResources.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