diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-06-08 12:18:08 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-06-09 07:19:26 +0200 |
commit | 0380b9d1f451affec186f197189a4e0ca87336ab (patch) | |
tree | 6e0d457e07a685eb1f1f841895a3636f04bc42bd /infra/it/it-test/src/test/java/io/fd | |
parent | d500e65e12ce0ceaa59d30283fabde08ee3bffea (diff) |
Move ordering logic out of AbstractSubtreeManagerRegistryBuilderBuilder
Introduces YangDAG that maintains topological order for yang schema
nodes and can be used by other components to read additional graph edges,
e.g. from file (HONEYCOMB-365).
Change-Id: Ia3046d38ffb4ca222412309f6c4391afc9315bd2
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/it/it-test/src/test/java/io/fd')
4 files changed, 39 insertions, 25 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 143317be0..53fd2e922 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,6 +16,22 @@ 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; @@ -28,15 +44,27 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.read.Reader; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; +import io.fd.honeycomb.translate.util.YangDAG; 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.*; +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.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; @@ -55,20 +83,7 @@ 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 private ReadContext ctx; private ReaderRegistry registry; @@ -108,7 +123,7 @@ public class HoneycombReadInfraTest extends AbstractInfraTest { } private void initReaderRegistry() { - registry = new CompositeReaderRegistryBuilder() + registry = new CompositeReaderRegistryBuilder(new YangDAG()) .add(containerWithListReader) // 2 .addBefore(simpleContainerReader, Ids.CONTAINER_WITH_LIST_ID) // 1 .add(simpleAugmentReader) // 1.1 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 b513b5886..b586a186c 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 @@ -26,18 +26,15 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import com.google.common.util.concurrent.CheckedFuture; import io.fd.honeycomb.translate.impl.read.GenericListReader; +import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; import io.fd.honeycomb.translate.read.ListReader; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.read.Reader; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; +import io.fd.honeycomb.translate.util.YangDAG; 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; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.ContainerWithList; @@ -85,7 +82,7 @@ public class HoneycombSubtreeReadInfraTest extends AbstractInfraTest { } private void initReaderRegistry() { - registry = new CompositeReaderRegistryBuilder() + registry = new CompositeReaderRegistryBuilder(new YangDAG()) // Subtree reader handling its child list .subtreeAdd(Sets.newHashSet(Ids.LIST_IN_CONTAINER_ID), containerWithListReader) // Reflexive diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java index bd51e39de..b98c91214 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java @@ -30,8 +30,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import io.fd.honeycomb.data.DataModification; import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder; -import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.honeycomb.translate.util.YangDAG; import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.translate.write.Writer; import io.fd.honeycomb.translate.write.registry.WriterRegistry; import java.util.ArrayList; @@ -116,7 +117,7 @@ public class HoneycombWriteInfraTest extends AbstractInfraTest { } private void initWriterRegistry() { - writerRegistry = new FlatWriterRegistryBuilder() + writerRegistry = new FlatWriterRegistryBuilder(new YangDAG()) .add(complexAugmentWriter) // unordered .add(nestedListWriter) // 6 .addAfter(listInContainerWriter, Ids.NESTED_LIST_ID) // 7 @@ -473,7 +474,7 @@ public class HoneycombWriteInfraTest extends AbstractInfraTest { @Test public void testSubtreeWriter() throws Exception { - writerRegistry = new FlatWriterRegistryBuilder() + writerRegistry = new FlatWriterRegistryBuilder(new YangDAG()) // Handles also container from grouping .subtreeAdd(Sets.newHashSet(Ids.CONTAINER_FROM_GROUPING_ID), containerWithChoiceWriter) .build(); diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/NestedAugmentationWriteTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/NestedAugmentationWriteTest.java index 351b88e4a..3b7d4a1cb 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/NestedAugmentationWriteTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/NestedAugmentationWriteTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import io.fd.honeycomb.data.DataModification; import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder; +import io.fd.honeycomb.translate.util.YangDAG; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.Writer; import io.fd.honeycomb.translate.write.registry.WriterRegistry; @@ -132,7 +133,7 @@ public class NestedAugmentationWriteTest extends AbstractInfraTest { } private void initWriterRegistry() { - writerRegistry = new FlatWriterRegistryBuilder() + writerRegistry = new FlatWriterRegistryBuilder(new YangDAG()) .add(augTargetWriter) .add(fromAugmentWriter) .add(listFromAugmentWriter) |