Remove a constructor unnecessary due to the custom serializer
Change-Id: Iac2e46a73b5c6391be201c1fd6b6da2d30abd26f
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EncodableDiscreteResources.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EncodableDiscreteResources.java
index 125b5d9..a3cc840 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EncodableDiscreteResources.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EncodableDiscreteResources.java
@@ -71,12 +71,6 @@
this.map = map;
}
- // for serializer
- private EncodableDiscreteResources() {
- this.parent = null;
- this.map = null;
- }
-
@Override
public Optional<DiscreteResource> lookup(DiscreteResourceId id) {
DiscreteResource resource = Resources.discrete(id).resource();
diff --git a/core/store/dist/src/test/java/org/onosproject/store/resource/impl/EncodableDiscreteResourcesTest.java b/core/store/dist/src/test/java/org/onosproject/store/resource/impl/EncodableDiscreteResourcesTest.java
index a1bd3d6..b5785f6 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/resource/impl/EncodableDiscreteResourcesTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/resource/impl/EncodableDiscreteResourcesTest.java
@@ -22,13 +22,34 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.resource.DiscreteResource;
import org.onosproject.net.resource.Resources;
+import org.onosproject.store.service.Serializer;
import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class EncodableDiscreteResourcesTest {
+ private final Serializer serializer = ConsistentResourceStore.SERIALIZER;
+
+ @Test
+ public void testPortSerialize() {
+ DiscreteResource device = Resources.discrete(DeviceId.deviceId("a")).resource();
+ Set<DiscreteResource> resources = IntStream.range(0, 100)
+ .mapToObj(PortNumber::portNumber)
+ .map(device::child)
+ .collect(Collectors.toSet());
+
+ DiscreteResources original = EncodableDiscreteResources.of(resources);
+
+ byte[] bytes = serializer.encode(original);
+ DiscreteResources decoded = serializer.decode(bytes);
+ assertThat(decoded, is(original));
+ }
+
@Test
public void testIfResourceIsFound() {
DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource();