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%2FShardRecoveryCoordinatorTest.java;h=4ad48a1d8301de1a19a70349cae12e1cacb798bd;hb=04f22714755ee8e52a63386cc1f4290402659838;hp=4467817a212fa752a557a36c1cf8ec91a2aecfd5;hpb=0c2d8a6530db21b1ca89aff8ee3812aa801cddac;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java index 4467817a21..4ad48a1d83 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java @@ -5,15 +5,14 @@ * 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; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import com.google.common.base.Optional; import java.io.IOException; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -25,10 +24,12 @@ import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +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.DataTreeSnapshot; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException; @@ -57,7 +58,8 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } @Test - public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException { + public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException, + DataValidationFailedException { try { coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar())); } catch (final SchemaValidationFailedException e) { @@ -68,7 +70,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } @Test - public void testApplyRecoverySnapshot() { + public void testApplyRecoverySnapshot() throws DataValidationFailedException { coordinator.applyRecoverySnapshot(createSnapshot()); assertFalse(readCars(peopleDataTree).isPresent()); @@ -85,9 +87,9 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } } - private DataTreeCandidateTip createCar() { - final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - dataTree.setSchemaContext(carsSchemaContext); + private DataTreeCandidate createCar() throws DataValidationFailedException { + final DataTree dataTree = new InMemoryDataTreeFactory().create( + DataTreeConfiguration.DEFAULT_OPERATIONAL, carsSchemaContext); final DataTreeSnapshot snapshot = dataTree.takeSnapshot(); @@ -99,7 +101,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } private Optional> readCars(final ShardDataTree shardDataTree) { - final TipProducingDataTree dataTree = shardDataTree.getDataTree(); + final DataTree dataTree = shardDataTree.getDataTree(); // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); @@ -107,16 +109,16 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } private Optional> readPeople(final ShardDataTree shardDataTree) { - final TipProducingDataTree dataTree = shardDataTree.getDataTree(); + final DataTree dataTree = shardDataTree.getDataTree(); // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); return shardDataTree.readNode(PeopleModel.BASE_PATH); } - private static ShardSnapshotState createSnapshot() { - final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, + private static ShardSnapshotState createSnapshot() throws DataValidationFailedException { + final DataTree dataTree = new InMemoryDataTreeFactory().create( + DataTreeConfiguration.DEFAULT_OPERATIONAL, SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, SchemaContextHelper.PEOPLE_YANG)); DataTreeSnapshot snapshot = dataTree.takeSnapshot(); @@ -129,6 +131,6 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { dataTree.commit(dataTree.prepare(modification)); return new ShardSnapshotState(new MetadataShardDataTreeSnapshot(dataTree.takeSnapshot().readNode( - YangInstanceIdentifier.EMPTY).get())); + YangInstanceIdentifier.empty()).get())); } }