diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-09-07 17:15:09 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-09-07 17:27:47 +0200 |
commit | b589b5bb6fc4b88f74710010782b155c80433740 (patch) | |
tree | bb51521070193f3b02fb025d76851ffbdfcfea7c /infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java | |
parent | e57cf1af53bd85befbd50ebc768f56f8a590c019 (diff) |
HONEYCOMB-194 Increase data-impl coverage to 87%
Change-Id: I1bd6d6ad2e8d35322346aa658e74413ce2d889f0
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java')
-rw-r--r-- | infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java index 2b4cc2a06..e795fbe44 100644 --- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java +++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegatorTest.java @@ -16,6 +16,7 @@ package io.fd.honeycomb.data.impl; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -32,13 +33,16 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; import java.util.Collections; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -48,6 +52,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.yangtools.util.UnmodifiableCollection; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; @@ -55,7 +60,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class ReadableDataTreeDelegatorTest { @@ -189,4 +196,24 @@ public class ReadableDataTreeDelegatorTest { assertEquals(SchemaContext.NAME, rootNode.getIdentifier().getNodeType()); assertEquals(vppStateContainer, Iterables.getOnlyElement(rootNode.getValue())); } + + + @Test + public void testWrapMixin() throws Exception { + final QName nodeQName = QName.create("namespace", "node"); + final QName keyQName = QName.create("namespace", "key"); + final List<NormalizedNode<?, ?>> mapNodes = Lists.newArrayList("one", "two", "three").stream() + .map(value -> ImmutableNodes.mapEntry(nodeQName, keyQName, value)) + .collect(Collectors.toList()); + final ListSchemaNode listSchema = mock(ListSchemaNode.class); + doReturn(Collections.singletonList(keyQName)).when(listSchema).getKeyDefinition(); + doReturn(true).when(listSchema).isUserOrdered(); + doReturn(nodeQName).when(listSchema).getQName(); + + final DataContainerChild<?, ?> dataContainerChild = + ReadableDataTreeDelegator.wrapListIntoMixinNode(mapNodes, listSchema); + + // asserting as arrays, since UnmodifiableCollection has no equals + assertArrayEquals(mapNodes.toArray(), ((UnmodifiableCollection) dataContainerChild.getValue()).toArray()); + } }
\ No newline at end of file |