import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class TestModel {
+public final class TestModel {
public static final QName TEST_QNAME = QName.create(
"urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
public static final QName SHOE_QNAME = QName.create(TEST_QNAME, "shoe");
public static final QName ANY_XML_QNAME = QName.create(TEST_QNAME, "any");
+ public static final QName EMPTY_QNAME = QName.create(TEST_QNAME, "empty-leaf");
public static final QName INVALID_QNAME = QName.create(TEST_QNAME, "invalid");
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
private static final String DATASTORE_AUG_YANG = "/odl-datastore-augmentation.yang";
private static final String DATASTORE_TEST_NOTIFICATION_YANG = "/odl-datastore-test-notification.yang";
-
public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier
.builder(TEST_PATH).node(DESC_QNAME).build();
.build()) //
.build();
- public static final InputStream getDatastoreTestInputStream() {
+ private TestModel() {
+ throw new UnsupportedOperationException();
+ }
+
+ public static InputStream getDatastoreTestInputStream() {
return getInputStream(DATASTORE_TEST_YANG);
}
- public static final InputStream getDatastoreAugInputStream() {
+ public static InputStream getDatastoreAugInputStream() {
return getInputStream(DATASTORE_AUG_YANG);
}
- public static final InputStream getDatastoreTestNotificationInputStream() {
+ public static InputStream getDatastoreTestNotificationInputStream() {
return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG);
}
}
public static SchemaContext createTestContext() {
- List<InputStream> inputStreams = new ArrayList<>();
- inputStreams.add(getDatastoreTestInputStream());
- inputStreams.add(getDatastoreAugInputStream());
- inputStreams.add(getDatastoreTestNotificationInputStream());
-
- return resolveSchemaContext(inputStreams);
+ return YangParserTestUtils.parseYangResources(TestModel.class, DATASTORE_TEST_YANG, DATASTORE_AUG_YANG,
+ DATASTORE_TEST_NOTIFICATION_YANG);
}
public static SchemaContext createTestContextWithoutTestSchema() {
- List<InputStream> inputStreams = new ArrayList<>();
- inputStreams.add(getDatastoreTestNotificationInputStream());
-
- return resolveSchemaContext(inputStreams);
+ return YangParserTestUtils.parseYangResource(DATASTORE_TEST_NOTIFICATION_YANG);
}
-
public static SchemaContext createTestContextWithoutAugmentationSchema() {
- List<InputStream> inputStreams = new ArrayList<>();
- inputStreams.add(getDatastoreTestInputStream());
- inputStreams.add(getDatastoreTestNotificationInputStream());
-
- return resolveSchemaContext(inputStreams);
- }
-
- private static SchemaContext resolveSchemaContext(final List<InputStream> streams) {
- try {
- return YangParserTestUtils.parseYangStreams(streams);
- } catch (ReactorException e) {
- throw new RuntimeException("Unable to build schema context from " + streams, e);
- }
+ return YangParserTestUtils.parseYangResources(TestModel.class, DATASTORE_TEST_YANG,
+ DATASTORE_TEST_NOTIFICATION_YANG);
}
/**