Search in sources :

Example 26 with DiscreteResource

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

the class CodecsTest method isMplsEncodable.

/**
 * Checks that it's possible to encode a MPLS label.
 */
@Test
public void isMplsEncodable() {
    DiscreteResource resource = Resources.discrete(DID, PN, MPLS).resource();
    assertThat(sut.isEncodable(resource), is(true));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 27 with DiscreteResource

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

the class EmptyDiscreteResourcesTest method testContainsAny.

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

Example 28 with DiscreteResource

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

the class EncodedDiscreteResourcesTest method testDifference.

@Test
public void testDifference() {
    DiscreteResource res1 = Resources.discrete(DID, PN, VID1).resource();
    DiscreteResource res2 = Resources.discrete(DID, PN, VID2).resource();
    DiscreteResource res3 = Resources.discrete(DID, PN, VID3).resource();
    EncodedDiscreteResources sut = EncodedDiscreteResources.of(ImmutableSet.of(res1, res2), new VlanIdCodec());
    EncodedDiscreteResources other = EncodedDiscreteResources.of(ImmutableSet.of(res1, res3), new VlanIdCodec());
    assertThat(sut.difference(other), is(EncodedDiscreteResources.of(ImmutableSet.of(res2), new VlanIdCodec())));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 29 with DiscreteResource

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

the class EncodedDiscreteResourcesTest method testContains.

@Test
public void testContains() {
    DiscreteResource res1 = Resources.discrete(DID, PN, VID1).resource();
    DiscreteResource res2 = Resources.discrete(DID, PN, VID2).resource();
    DiscreteResource res3 = Resources.discrete(DID, PN, VID3).resource();
    Set<DiscreteResource> resources = ImmutableSet.of(res1, res2);
    EncodedDiscreteResources sut = EncodedDiscreteResources.of(resources, new VlanIdCodec());
    assertThat(sut.contains(res1), is(true));
    assertThat(sut.contains(res3), is(false));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 30 with DiscreteResource

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

the class EncodedDiscreteResourcesTest method testAdd.

@Test
public void testAdd() {
    DiscreteResource res1 = Resources.discrete(DID, PN, VID1).resource();
    DiscreteResource res2 = Resources.discrete(DID, PN, VID2).resource();
    DiscreteResource res3 = Resources.discrete(DID, PN, VID3).resource();
    EncodedDiscreteResources sut = EncodedDiscreteResources.of(ImmutableSet.of(res1, res2), new VlanIdCodec());
    EncodedDiscreteResources other = EncodedDiscreteResources.of(ImmutableSet.of(res1, res3), new VlanIdCodec());
    assertThat(sut.add(other), is(EncodedDiscreteResources.of(ImmutableSet.of(res1, res2, res3), new VlanIdCodec())));
}
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