import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-import com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
}
private static DataTree initDataTree(final EffectiveModelContext schemaContext, final boolean withMapNode)
- throws DataValidationFailedException {
+ throws Exception {
final var inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
}
@Test
- void writeInvalidContainerTest() throws DataValidationFailedException {
+ void writeInvalidContainerTest() throws Exception {
final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final var myList = createMap(true);
}
@Test
- void writeInvalidMapTest() throws DataValidationFailedException {
+ void writeInvalidMapTest() throws Exception {
final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
writeMap(modificationTree, true);
}
@Test
- void writeInvalidMapEntryTest() throws DataValidationFailedException {
+ void writeInvalidMapEntryTest() throws Exception {
final var inMemoryDataTree = initDataTree(SCHEMA_CONTEXT, true);
final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
}
private static void writeMap(final DataTreeModification modificationTree, final boolean mandatoryDataMissing) {
- modificationTree.write(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMap(mandatoryDataMissing));
+ modificationTree.write(YangInstanceIdentifier.of(ROOT, MY_LIST), createMap(mandatoryDataMissing));
}
private static SystemMapNode createMap(final boolean mandatoryDataMissing) {
}
private static void writeMapEntry(final DataTreeModification modificationTree, final Object listIdValue,
- final Object mandatoryLeafValue, final Object commonLeafValue) throws DataValidationFailedException {
+ final Object mandatoryLeafValue, final Object commonLeafValue) {
final var taskEntryNode = mandatoryLeafValue == null ? createMapEntry(listIdValue, commonLeafValue)
: createMapEntry(listIdValue, mandatoryLeafValue, commonLeafValue);
modificationTree.write(
- YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
- taskEntryNode);
+ YangInstanceIdentifier.of(ROOT, MY_LIST)
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue)),
+ taskEntryNode);
}
private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
final Object commonLeafValue) {
return ImmutableNodes.newMapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
- .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
- .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
- .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue))
+ .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
+ .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
+ .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue))
+ .build();
}
private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue) {
return ImmutableNodes.newMapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
- .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
- .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue))
+ .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
+ .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue))
+ .build();
}
@Test
- void writeValidContainerTest() throws DataValidationFailedException {
+ void writeValidContainerTest() throws Exception {
final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final var myList = createMap(false);
}
@Test
- void writeValidMapTest() throws DataValidationFailedException {
+ void writeValidMapTest() throws Exception {
final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
writeMap(modificationTree, false);
}
@Test
- void writeValidMapEntryTest() throws DataValidationFailedException {
+ void writeValidMapEntryTest() throws Exception {
final var inMemoryDataTree = initDataTree(SCHEMA_CONTEXT, true);
final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();