X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futil%2FTestModel.java;h=72b8a3bb7f2e3eea6f325ba3753a83338087c12d;hp=bb572e32090d80f577143ee190147738f5e759e9;hb=20a32e6459fd1e27e7669bf1ebc7742b96787b94;hpb=4e696d9795fe7eef40369c05c340d137394126f3 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java index bb572e3209..72b8a3bb7f 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java @@ -17,10 +17,8 @@ import com.google.common.collect.ImmutableSet; 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; @@ -49,11 +47,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe 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.parser.stmt.reactor.CrossSourceStatementReactor; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; +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", @@ -103,7 +99,6 @@ public class TestModel { 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(); @@ -157,15 +152,19 @@ public class TestModel { .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); } @@ -174,40 +173,17 @@ public class TestModel { } public static SchemaContext createTestContext() { - List 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 inputStreams = new ArrayList<>(); - inputStreams.add(getDatastoreTestNotificationInputStream()); - - return resolveSchemaContext(inputStreams); + return YangParserTestUtils.parseYangResource(DATASTORE_TEST_NOTIFICATION_YANG); } - public static SchemaContext createTestContextWithoutAugmentationSchema() { - List inputStreams = new ArrayList<>(); - inputStreams.add(getDatastoreTestInputStream()); - inputStreams.add(getDatastoreTestNotificationInputStream()); - - return resolveSchemaContext(inputStreams); - } - - private static SchemaContext resolveSchemaContext(List streams) { - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - final SchemaContext schemaContext; - - try { - schemaContext = reactor.buildEffective(streams); - } catch (ReactorException e) { - throw new RuntimeException("Unable to build schema context from " + streams, e); - } - return schemaContext; + return YangParserTestUtils.parseYangResources(TestModel.class, DATASTORE_TEST_YANG, + DATASTORE_TEST_NOTIFICATION_YANG); } /** @@ -227,8 +203,7 @@ public class TestModel { * * */ - public static NormalizedNode createDocumentOne( - SchemaContext schemaContext) { + public static NormalizedNode createDocumentOne(final SchemaContext schemaContext) { return ImmutableContainerNodeBuilder .create() .withNodeIdentifier( @@ -360,7 +335,7 @@ public class TestModel { return createBaseTestContainerBuilder().build(); } - public static MapEntryNode createAugmentedListEntry(int id, String name) { + public static MapEntryNode createAugmentedListEntry(final int id, final String name) { Set childAugmentations = new HashSet<>(); childAugmentations.add(AUG_CONT_QNAME);