+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.md.cluster.datastore.model;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
public class CompositeModel {
"urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
"2014-03-13", "name");
+ public static final QName AUG_CONTAINER = QName.create(AUG_QNAME, "aug-container");
+ public static final QName AUG_INNER_CONTAINER = QName.create(AUG_QNAME, "aug-inner-container");
public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
"outer-list");
}
private static InputStream getInputStream(final String resourceName) {
- return TestModel.class.getResourceAsStream(resourceName);
+ return CompositeModel.class.getResourceAsStream(resourceName);
}
public static SchemaContext createTestContext() {
inputStreams.add(getDatastoreAugInputStream());
inputStreams.add(getDatastoreTestNotificationInputStream());
- YangParserImpl parser = new YangParserImpl();
- Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
- return parser.resolveSchemaContext(modules);
+ final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ final SchemaContext schemaContext;
+
+ try {
+ schemaContext = reactor.buildEffective(inputStreams);
+ } catch (ReactorException e) {
+ throw new RuntimeException("Unable to build schema context from " + inputStreams, e);
+ }
+ return schemaContext;
}
/**
ImmutableLeafSetEntryNodeBuilder
.create()
.withNodeIdentifier(
- new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME,
+ new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME,
"shoe"), "nike")).withValue("nike").build();
final LeafSetEntryNode<Object> puma =
ImmutableLeafSetEntryNodeBuilder
.create()
.withNodeIdentifier(
- new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME,
+ new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME,
"shoe"), "puma")).withValue("puma").build();
final LeafSetNode<Object> shoes =
ImmutableLeafSetNodeBuilder
ImmutableLeafSetEntryNodeBuilder
.create()
.withNodeIdentifier(
- (new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME,
+ (new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME,
"number"), 5))).withValue(5).build();
final LeafSetEntryNode<Object> fifteen =
ImmutableLeafSetEntryNodeBuilder
.create()
.withNodeIdentifier(
- (new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME,
+ (new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME,
"number"), 15))).withValue(15).build();
final LeafSetNode<Object> numbers =
ImmutableLeafSetNodeBuilder
Set<QName> childAugmentations = new HashSet<>();
childAugmentations.add(AUG_QNAME);
final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
- new YangInstanceIdentifier.AugmentationIdentifier(null, childAugmentations);
+ new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
final AugmentationNode augmentationNode =
Builders.augmentationBuilder()
.withNodeIdentifier(augmentationIdentifier)