Resource API changes as preparation for hierarchy support (ONOS-2446)
The changes:
- Introduce ResourcePath to point a resource
- Remove Resource interface
- Make ResourceAllocation concrete class and remove DefaultResourceAllocation
- Remove DefaultResource
- Changes in interfaces due to the above changes
Change-Id: I0f3f846be67b0f7917117943aac31e3099c851ec
diff --git a/core/net/src/test/java/org/onosproject/net/newresource/impl/ResourceManagerTest.java b/core/net/src/test/java/org/onosproject/net/newresource/impl/ResourceManagerTest.java
index f3b61fc..ae6d103 100644
--- a/core/net/src/test/java/org/onosproject/net/newresource/impl/ResourceManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/newresource/impl/ResourceManagerTest.java
@@ -22,12 +22,12 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.LinkKey;
import org.onosproject.net.PortNumber;
-import org.onosproject.net.newresource.DefaultResource;
+import org.onosproject.net.newresource.ResourcePath;
import java.util.function.Predicate;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
/**
* Unit tests for ResourceManager.
@@ -60,19 +60,19 @@
LinkKey linkKey = LinkKey.linkKey(CP1_1, CP2_1);
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) (VLAN_LOWER_LIMIT - 1)))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) (VLAN_LOWER_LIMIT - 1)))),
is(false));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId(VLAN_LOWER_LIMIT))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId(VLAN_LOWER_LIMIT))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) 100))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) 100))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) (VLAN_UPPER_LIMIT - 1)))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) (VLAN_UPPER_LIMIT - 1)))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId(VLAN_UPPER_LIMIT))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId(VLAN_UPPER_LIMIT))),
is(false));
}
@@ -83,19 +83,19 @@
public void testWhenBoundaryNotSet() {
LinkKey linkKey = LinkKey.linkKey(CP1_1, CP2_1);
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) (VLAN_LOWER_LIMIT - 1)))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) (VLAN_LOWER_LIMIT - 1)))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId(VLAN_LOWER_LIMIT))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId(VLAN_LOWER_LIMIT))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) 100))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) 100))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId((short) (VLAN_UPPER_LIMIT - 1)))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId((short) (VLAN_UPPER_LIMIT - 1)))),
is(true));
- assertThat(manager.isValid(new DefaultResource<>(linkKey, VlanId.vlanId(VLAN_UPPER_LIMIT))),
+ assertThat(manager.isValid(new ResourcePath(linkKey, VlanId.vlanId(VLAN_UPPER_LIMIT))),
is(true));
}
}