From: Robert Varga Date: Sun, 19 Jan 2020 10:20:08 +0000 (+0100) Subject: Rework PruningDataTreeModificationTest X-Git-Tag: release/magnesium~13 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=32286c6be27033489950d40e6708a73abdb3c92f Rework PruningDataTreeModificationTest Eliminate the use of a dedicated constructor, ensure invariants are shared across tests. JIRA: CONTROLLER-1923 Change-Id: Ieaec8bafcb7c2f6bf4fe22815b1b14f84d396ef9 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java index 3c326dc2df..f69a22e5b6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java @@ -47,11 +47,6 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat this.pruner = requireNonNull(pruner); } - public PruningDataTreeModification(final DataTreeModification delegate, final DataTree dataTree, - final SchemaContext schemaContext) { - this(delegate, dataTree, ReusableNormalizedNodePruner.forSchemaContext(schemaContext)); - } - public PruningDataTreeModification(final DataTreeModification delegate, final DataTree dataTree, final DataSchemaContextTree dataSchemaContext) { this(delegate, dataTree, ReusableNormalizedNodePruner.forDataSchemaContext(dataSchemaContext)); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java index 73db5465b5..50179c706b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.datastore.utils; import static org.junit.Assert.assertEquals; @@ -27,10 +26,12 @@ import com.google.common.reflect.Reflection; import java.lang.reflect.InvocationTargetException; import java.util.Optional; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.controller.cluster.datastore.Shard; import org.opendaylight.controller.cluster.datastore.ShardDataTree; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; @@ -54,15 +55,17 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException; +import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +@RunWith(MockitoJUnitRunner.class) public class PruningDataTreeModificationTest { - static final SchemaContext SCHEMA_CONTEXT = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, - SchemaContextHelper.ODL_DATASTORE_TEST_YANG); - static final QName INVALID_TEST_QNAME = QName.create(TestModel.TEST_QNAME, "invalid"); static final YangInstanceIdentifier INVALID_TEST_PATH = YangInstanceIdentifier.of(INVALID_TEST_QNAME); + private static SchemaContext SCHEMA_CONTEXT; + private static DataSchemaContextTree CONTEXT_TREE; + @Mock private DataTreeModification mockModification; @@ -71,11 +74,16 @@ public class PruningDataTreeModificationTest { private DataTreeModification proxyModification; private PruningDataTreeModification pruningDataTreeModification; + @BeforeClass + public static void beforeClass() { + SCHEMA_CONTEXT = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, + SchemaContextHelper.ODL_DATASTORE_TEST_YANG); + CONTEXT_TREE = DataSchemaContextTree.from(SCHEMA_CONTEXT); + } + @Before @SuppressWarnings("checkstyle:avoidHidingCauseException") public void setUp() { - MockitoAnnotations.initMocks(this); - dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT); @@ -89,7 +97,7 @@ public class PruningDataTreeModificationTest { } }); - pruningDataTreeModification = new PruningDataTreeModification(proxyModification, dataTree, SCHEMA_CONTEXT); + pruningDataTreeModification = new PruningDataTreeModification(proxyModification, dataTree, CONTEXT_TREE); } @Test