Committed by
Gerrit Code Review
Remove a constructor unnecessary due to the custom serializer
Change-Id: Iac2e46a73b5c6391be201c1fd6b6da2d30abd26f
Showing
2 changed files
with
21 additions
and
6 deletions
... | @@ -71,12 +71,6 @@ final class EncodableDiscreteResources implements DiscreteResources { | ... | @@ -71,12 +71,6 @@ final class EncodableDiscreteResources implements DiscreteResources { |
71 | this.map = map; | 71 | this.map = map; |
72 | } | 72 | } |
73 | 73 | ||
74 | - // for serializer | ||
75 | - private EncodableDiscreteResources() { | ||
76 | - this.parent = null; | ||
77 | - this.map = null; | ||
78 | - } | ||
79 | - | ||
80 | @Override | 74 | @Override |
81 | public Optional<DiscreteResource> lookup(DiscreteResourceId id) { | 75 | public Optional<DiscreteResource> lookup(DiscreteResourceId id) { |
82 | DiscreteResource resource = Resources.discrete(id).resource(); | 76 | DiscreteResource resource = Resources.discrete(id).resource(); | ... | ... |
... | @@ -22,13 +22,34 @@ import org.onosproject.net.DeviceId; | ... | @@ -22,13 +22,34 @@ import org.onosproject.net.DeviceId; |
22 | import org.onosproject.net.PortNumber; | 22 | import org.onosproject.net.PortNumber; |
23 | import org.onosproject.net.resource.DiscreteResource; | 23 | import org.onosproject.net.resource.DiscreteResource; |
24 | import org.onosproject.net.resource.Resources; | 24 | import org.onosproject.net.resource.Resources; |
25 | +import org.onosproject.store.service.Serializer; | ||
25 | 26 | ||
26 | import java.util.Optional; | 27 | import java.util.Optional; |
28 | +import java.util.Set; | ||
29 | +import java.util.stream.Collectors; | ||
30 | +import java.util.stream.IntStream; | ||
27 | 31 | ||
28 | import static org.hamcrest.Matchers.is; | 32 | import static org.hamcrest.Matchers.is; |
29 | import static org.junit.Assert.assertThat; | 33 | import static org.junit.Assert.assertThat; |
30 | 34 | ||
31 | public class EncodableDiscreteResourcesTest { | 35 | public class EncodableDiscreteResourcesTest { |
36 | + private final Serializer serializer = ConsistentResourceStore.SERIALIZER; | ||
37 | + | ||
38 | + @Test | ||
39 | + public void testPortSerialize() { | ||
40 | + DiscreteResource device = Resources.discrete(DeviceId.deviceId("a")).resource(); | ||
41 | + Set<DiscreteResource> resources = IntStream.range(0, 100) | ||
42 | + .mapToObj(PortNumber::portNumber) | ||
43 | + .map(device::child) | ||
44 | + .collect(Collectors.toSet()); | ||
45 | + | ||
46 | + DiscreteResources original = EncodableDiscreteResources.of(resources); | ||
47 | + | ||
48 | + byte[] bytes = serializer.encode(original); | ||
49 | + DiscreteResources decoded = serializer.decode(bytes); | ||
50 | + assertThat(decoded, is(original)); | ||
51 | + } | ||
52 | + | ||
32 | @Test | 53 | @Test |
33 | public void testIfResourceIsFound() { | 54 | public void testIfResourceIsFound() { |
34 | DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource(); | 55 | DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)).resource(); | ... | ... |
-
Please register or login to post a comment