X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FPruningDataTreeModificationTest.java;h=18949ac21ecd5ec3d491933b9f15e0041a8f79fe;hb=698d49f09d9ba58bf400578742a7ac1b06349f11;hp=7a8d065b14e0834a8ad0e921d3285b5d2af2fee9;hpb=5464f50be733df1bbbe31cf05665d542d3b7c5e7;p=controller.git 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 7a8d065b14..18949ac21e 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 @@ -23,9 +23,9 @@ import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.i import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.outerNode; import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.outerNodeEntry; -import com.google.common.base.Optional; import com.google.common.reflect.Reflection; import java.lang.reflect.InvocationTargetException; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -43,12 +43,12 @@ 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.api.schema.tree.DataTree; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; @@ -66,17 +66,18 @@ public class PruningDataTreeModificationTest { @Mock private DataTreeModification mockModification; - private TipProducingDataTree dataTree; + private DataTree dataTree; private DataTreeModification realModification; private DataTreeModification proxyModification; private PruningDataTreeModification pruningDataTreeModification; @Before + @SuppressWarnings("checkstyle:avoidHidingCauseException") public void setUp() { MockitoAnnotations.initMocks(this); - dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); - dataTree.setSchemaContext(SCHEMA_CONTEXT); + dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, + SCHEMA_CONTEXT); realModification = dataTree.takeSnapshot().newModification(); proxyModification = Reflection.newProxy(DataTreeModification.class, (proxy, method, args) -> { @@ -127,7 +128,7 @@ public class PruningDataTreeModificationTest { verify(mockModification, times(1)).merge(path, normalizedNode); - DataTreeCandidateTip candidate = getCandidate(); + DataTreeCandidate candidate = getCandidate(); assertEquals("getModificationType", ModificationType.UNMODIFIED, candidate.getRootNode().getModificationType()); } @@ -152,7 +153,7 @@ public class PruningDataTreeModificationTest { new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode).build(); Optional> actual = dataTree.takeSnapshot().readNode(path); - assertEquals("After pruning present", true, actual.isPresent()); + assertTrue("After pruning present", actual.isPresent()); assertEquals("After pruning", prunedNode, actual.get()); } @@ -165,7 +166,7 @@ public class PruningDataTreeModificationTest { verify(mockModification, times(1)).merge(path, normalizedNode); - DataTreeCandidateTip candidate = getCandidate(); + DataTreeCandidate candidate = getCandidate(); assertEquals("getModificationType", ModificationType.UNMODIFIED, candidate.getRootNode().getModificationType()); } @@ -180,8 +181,8 @@ public class PruningDataTreeModificationTest { @Test public void testWriteRootNode() throws Exception { - final DataTree localDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); - localDataTree.setSchemaContext(SCHEMA_CONTEXT); + final DataTree localDataTree = new InMemoryDataTreeFactory().create( + DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT); DataTreeModification mod = localDataTree.takeSnapshot().newModification(); mod.write(CarsModel.BASE_PATH, CarsModel.create()); @@ -194,7 +195,7 @@ public class PruningDataTreeModificationTest { dataTree.commit(getCandidate()); Optional> actual = dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY); - assertEquals("Root present", true, actual.isPresent()); + assertTrue("Root present", actual.isPresent()); assertEquals("Root node", normalizedNode, actual.get()); } @@ -226,7 +227,7 @@ public class PruningDataTreeModificationTest { verify(mockModification, times(1)).write(path, normalizedNode); - DataTreeCandidateTip candidate = getCandidate(); + DataTreeCandidate candidate = getCandidate(); assertEquals("getModificationType", ModificationType.UNMODIFIED, candidate.getRootNode().getModificationType()); } @@ -253,7 +254,7 @@ public class PruningDataTreeModificationTest { .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")).build(); Optional> actual = dataTree.takeSnapshot().readNode(path); - assertEquals("After pruning present", true, actual.isPresent()); + assertTrue("After pruning present", actual.isPresent()); assertEquals("After pruning", prunedNode, actual.get()); } @@ -288,12 +289,11 @@ public class PruningDataTreeModificationTest { dataTreeModification instanceof PruningDataTreeModification); } - private DataTreeCandidateTip getCandidate() throws DataValidationFailedException { + private DataTreeCandidate getCandidate() throws DataValidationFailedException { pruningDataTreeModification.ready(); DataTreeModification mod = pruningDataTreeModification.delegate(); mod = mod == proxyModification ? realModification : mod; dataTree.validate(mod); - DataTreeCandidateTip candidate = dataTree.prepare(mod); - return candidate; + return dataTree.prepare(mod); } }