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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations