Search in sources :

Example 41 with DiscreteResource

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

the class ResourceDeviceListener method unregisterDeviceResource.

private void unregisterDeviceResource(Device device) {
    DiscreteResource devResource = Resources.discrete(device.id()).resource();
    List<Resource> allResources = getDescendantResources(devResource);
    adminService.unregister(Lists.transform(allResources, Resource::id));
}
Also used : Resource(org.onosproject.net.resource.Resource) DiscreteResource(org.onosproject.net.resource.DiscreteResource) DiscreteResource(org.onosproject.net.resource.DiscreteResource)

Example 42 with DiscreteResource

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

the class GenericDiscreteResourcesTest method testDifferenceSerializable.

@Test
public void testDifferenceSerializable() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
    DiscreteResources set1 = GenericDiscreteResources.of(ImmutableSet.of(res1, res2));
    DiscreteResources set2 = GenericDiscreteResources.of(ImmutableSet.of(res1));
    DiscreteResources difference = set1.difference(set2);
    assertThat(serializer.decode(serializer.encode(difference)), is(difference));
}
Also used : DiscreteResource(org.onosproject.net.resource.DiscreteResource) Test(org.junit.Test)

Example 43 with DiscreteResource

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

the class GenericDiscreteResourcesTest method testNotEmpty.

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

Example 44 with DiscreteResource

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

the class GenericDiscreteResourcesTest method testContainsWithEmpty.

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

Example 45 with DiscreteResource

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

the class GenericDiscreteResourcesTest method testIfDifferenceIsNotChanged.

@Test
public void testIfDifferenceIsNotChanged() {
    DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
    DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
    DiscreteResources sut = GenericDiscreteResources.of(ImmutableSet.of(res1));
    DiscreteResources other = GenericDiscreteResources.of(ImmutableSet.of(res2));
    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