Sho SHIMIZU
Committed by Gerrit Code Review

Remove a constructor unnecessary due to the custom serializer

Change-Id: Iac2e46a73b5c6391be201c1fd6b6da2d30abd26f
......@@ -71,12 +71,6 @@ final class EncodableDiscreteResources implements DiscreteResources {
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();
......
......@@ -22,13 +22,34 @@ import org.onosproject.net.DeviceId;
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();
......