X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fcluster%2Fdatastore%2Fmodel%2FTestModel.java;h=cfbaee6f61b834db8042eb11fcc374094191c008;hp=cd8a75454c4298b83148eea0b226c3e9874dcd0d;hb=c8121ea6b5bf54c43777afe6a747be40637e1f42;hpb=c1336f9b497bc6867536a24f629c3f0b002ccb2f diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java index cd8a75454c..cfbaee6f61 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java @@ -7,11 +7,6 @@ */ package org.opendaylight.controller.md.cluster.datastore.model; -import com.google.common.io.Resources; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; @@ -23,10 +18,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; 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", "2014-03-13", "test"); @@ -37,7 +31,6 @@ public class TestModel { public static final QName JUNK_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:junk", "2014-03-13", "junk"); - public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); public static final QName OUTER_CONTAINER_QNAME = QName.create(TEST_QNAME, "outer-container"); public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); @@ -59,21 +52,16 @@ public class TestModel { public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two"); public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three"); - public static SchemaContext createTestContext() { - final List sources; + private TestModel() { - try { - sources = Collections.singletonList( - Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG)).openStream()); - } catch (IOException e1) { - throw new ExceptionInInitializerError(e1); - } + } - try { - return YangParserTestUtils.parseYangStreams(sources); - } catch (ReactorException e) { - throw new RuntimeException("Unable to build schema context from " + sources, e); - } + public static SchemaContext createTestContext() { + return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG); + } + + public static DataContainerChild outerMapNode() { + return ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME).build(); } public static DataContainerChild outerNode(final int... ids) { @@ -117,7 +105,7 @@ public class TestModel { } public static NodeIdentifierWithPredicates outerEntryKey(final int id) { - return new NodeIdentifierWithPredicates(OUTER_LIST_QNAME, ID_QNAME, id); + return NodeIdentifierWithPredicates.of(OUTER_LIST_QNAME, ID_QNAME, id); } public static YangInstanceIdentifier outerEntryPath(final int id) { @@ -125,10 +113,14 @@ public class TestModel { } public static NodeIdentifierWithPredicates innerEntryKey(final String name) { - return new NodeIdentifierWithPredicates(INNER_LIST_QNAME, NAME_QNAME, name); + return NodeIdentifierWithPredicates.of(INNER_LIST_QNAME, NAME_QNAME, name); } public static YangInstanceIdentifier innerEntryPath(final int id, final String name) { return OUTER_LIST_PATH.node(outerEntryKey(id)).node(INNER_LIST_QNAME).node(innerEntryKey(name)); } + + public static YangInstanceIdentifier innerMapPath(final int id) { + return OUTER_LIST_PATH.node(outerEntryKey(id)).node(INNER_LIST_QNAME); + } }