summaryrefslogtreecommitdiffstats
path: root/infra/it
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-02-24 10:39:55 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-02-27 11:42:19 +0000
commitec78f178f542369fdfd696fdc6e4bb872780ac87 (patch)
tree129206bdf7bb3ad62257d5cfca776e264f70fad6 /infra/it
parent309d5e1561ba42ee491fa33c3b8c24849dc003fa (diff)
HONEYCOMB-344 - structural reader for list
Change-Id: Ia02ed73daaeea547d49c9ec2d4d7d10f4db85b5e Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'infra/it')
-rw-r--r--infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java57
-rw-r--r--infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java20
2 files changed, 22 insertions, 55 deletions
diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java
index 6d4c9e6..143317b 100644
--- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java
+++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java
@@ -16,22 +16,6 @@
package io.fd.honeycomb.data.impl;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyListOf;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.atMost;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
@@ -47,23 +31,12 @@ import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.ReflexiveListReaderCustomizer;
import io.fd.honeycomb.translate.util.read.ReflexiveReaderCustomizer;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.exceptions.misusing.MockitoConfigurationException;
import org.mockito.invocation.InvocationOnMock;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.ComplexAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.ComplexAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.ContainerWithList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.ContainerWithListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.SimpleAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.SimpleAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.SimpleContainer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.SimpleContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.ListInContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.ListInContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.ListInContainerKey;
@@ -82,6 +55,18 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import javax.annotation.Nonnull;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
public class HoneycombReadInfraTest extends AbstractInfraTest {
@Mock
@@ -108,14 +93,14 @@ public class HoneycombReadInfraTest extends AbstractInfraTest {
// 2.1
private ListReader<ListInContainer, ListInContainerKey, ListInContainerBuilder> listInContainerReader =
mockListReader(Ids.LIST_IN_CONTAINER_ID, this::readListInContainer, this::getListInContainerIds,
- ListInContainerBuilder.class);
+ ListInContainerBuilder.class, ctx);
// 2.1.1
private Reader<ContainerInList, ContainerInListBuilder> containerInListReader =
mockReader(Ids.CONTAINER_IN_LIST_ID, this::readContainerInList, ContainerInListBuilder.class);
// 2.1.1.1
private ListReader<NestedList, NestedListKey, NestedListBuilder> nestedListReader =
mockListReader(Ids.NESTED_LIST_ID, this::readNestedList, this::getNestedListIds,
- NestedListBuilder.class);
+ NestedListBuilder.class, ctx);
@Override
void postSetup() {
@@ -293,17 +278,11 @@ public class HoneycombReadInfraTest extends AbstractInfraTest {
InstanceIdentifier<D> id,
CurrentAttributesReader<D, B> currentAttributesReader,
ListKeysReader<D, K> listKeysReader,
- Class<B> builderClass) {
+ Class<B> builderClass,
+ ReadContext ctx) {
ListReader<D, K, B> reflex = new GenericListReader<>(id,
- new ReflexiveListReaderCustomizer<D, K, B>(id.getTargetType(), builderClass) {
-
- @Nonnull
- @Override
- public List<K> getAllIds(@Nonnull final InstanceIdentifier<D> id, @Nonnull final ReadContext context)
- throws ReadFailedException {
- return listKeysReader.getAllIds(id, context);
- }
+ new ReflexiveListReaderCustomizer<D, K, B>(id.getTargetType(), builderClass, listKeysReader.getAllIds(id, ctx)) {
@Override
public void readCurrentAttributes(final InstanceIdentifier<D> id, final B builder,
diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java
index 1894f49..b513b58 100644
--- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java
+++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java
@@ -33,6 +33,8 @@ import io.fd.honeycomb.translate.read.Reader;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.util.read.ReflexiveListReaderCustomizer;
import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder;
+
+import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
@@ -61,22 +63,8 @@ public class HoneycombSubtreeReadInfraTest extends AbstractInfraTest {
private ListReader<ListInContainer, ListInContainerKey, ListInContainerBuilder> listInContainerReader =
new GenericListReader<>(Ids.LIST_IN_CONTAINER_ID,
- new ReflexiveListReaderCustomizer<ListInContainer, ListInContainerKey, ListInContainerBuilder>(Ids.LIST_IN_CONTAINER_ID.getTargetType(), ListInContainerBuilder.class) {
-
- @Nonnull
- @Override
- public List<ListInContainerKey> getAllIds(@Nonnull final InstanceIdentifier<ListInContainer> id,
- @Nonnull final ReadContext context)
- throws ReadFailedException {
- // This is the only way of extending subtree reader's list child
- // Reflexive list reader has to be used in place of the list(managed by subtree reader perent)
- // to enable further children readers. However, it will not work out of the box, because
- // reflexive list reader has no way to tell what are the IDs to correctly invoke its children.
- // Only way is to override the getAllIds method in reflexive reader and return the same list
- // as parent used (this can be done using cache or repeated dump call)
- return Lists.newArrayList(new ListInContainerKey(1L), new ListInContainerKey(2L));
- }
-
+ new ReflexiveListReaderCustomizer<ListInContainer, ListInContainerKey, ListInContainerBuilder>(Ids.LIST_IN_CONTAINER_ID.getTargetType(), ListInContainerBuilder.class,
+ Lists.newArrayList(new ListInContainerKey(1L), new ListInContainerKey(2L))) {
@Override
public void readCurrentAttributes(final InstanceIdentifier<ListInContainer> id,
final ListInContainerBuilder builder,