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.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;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger FOO_LOGGER = LoggerFactory.getLogger("foo");
private ShardDataTree peopleDataTree;
- private SchemaContext peopleSchemaContext;
- private SchemaContext carsSchemaContext;
+ private EffectiveModelContext peopleSchemaContext;
+ private EffectiveModelContext carsSchemaContext;
private ShardRecoveryCoordinator coordinator;
@Before
}
@Test
- public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
+ public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException,
+ DataValidationFailedException {
try {
coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
} catch (final SchemaValidationFailedException e) {
}
@Test
- public void testApplyRecoverySnapshot() {
+ public void testApplyRecoverySnapshot() throws DataValidationFailedException {
coordinator.applyRecoverySnapshot(createSnapshot());
assertFalse(readCars(peopleDataTree).isPresent());
}
}
- private DataTreeCandidate createCar() {
+ private DataTreeCandidate createCar() throws DataValidationFailedException {
final DataTree dataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_OPERATIONAL, carsSchemaContext);
private Optional<NormalizedNode<?,?>> readCars(final ShardDataTree shardDataTree) {
final DataTree dataTree = shardDataTree.getDataTree();
// FIXME: this should not be called here
- dataTree.setSchemaContext(peopleSchemaContext);
+ dataTree.setEffectiveModelContext(peopleSchemaContext);
return shardDataTree.readNode(CarsModel.BASE_PATH);
}
private Optional<NormalizedNode<?,?>> readPeople(final ShardDataTree shardDataTree) {
final DataTree dataTree = shardDataTree.getDataTree();
// FIXME: this should not be called here
- dataTree.setSchemaContext(peopleSchemaContext);
+ dataTree.setEffectiveModelContext(peopleSchemaContext);
return shardDataTree.readNode(PeopleModel.BASE_PATH);
}
- private static ShardSnapshotState createSnapshot() {
+ private static ShardSnapshotState createSnapshot() throws DataValidationFailedException {
final DataTree dataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_OPERATIONAL, SchemaContextHelper.select(SchemaContextHelper.CARS_YANG,
SchemaContextHelper.PEOPLE_YANG));
dataTree.commit(dataTree.prepare(modification));
return new ShardSnapshotState(new MetadataShardDataTreeSnapshot(dataTree.takeSnapshot().readNode(
- YangInstanceIdentifier.EMPTY).get()));
+ YangInstanceIdentifier.empty()).get()));
}
}