* 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.yangtools.yang.data.jaxen;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import java.net.URI;
-import java.text.ParseException;
import java.util.Set;
import org.jaxen.Context;
import org.jaxen.Function;
import org.jaxen.FunctionCallException;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
public class BitIsSetXPathFunctionTest {
- private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
-
- private static QNameModule fooModule;
- private static QName myContainer;
- private static QName myList;
- private static QName flags;
- private static QName ordinaryLeaf;
-
- @BeforeClass
- public static void setup() throws ParseException {
- jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
-
- fooModule = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
- myContainer = QName.create(fooModule, "my-container");
- myList = QName.create(fooModule, "my-list");
- flags = QName.create(fooModule, "flags");
- ordinaryLeaf = QName.create(fooModule, "ordinary-leaf");
- }
+ private static final JaxenSchemaContextFactory SCHEMA_CONTEXT_FACTORY = new JaxenSchemaContextFactory();
+ private static final QNameModule FOO_MODULE = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
+ private static final QName MY_CONTAINER = QName.create(FOO_MODULE, "my-container");
+ private static final QName MY_LIST = QName.create(FOO_MODULE, "my-list");
+ private static final QName FLAGS = QName.create(FOO_MODULE, "flags");
+ private static final QName ORDINARY_LEAF = QName.create(FOO_MODULE, "ordinary-leaf");
@Test
public void testBitIsSetFunction() throws Exception {
"/yang-xpath-functions-test/bit-is-set-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(setOfBits));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/bit-is-set-function/foo-invalid.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(setOfBits));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/bit-is-set-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(
invalidNodeValueType));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/bit-is-set-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(setOfBits));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
}
private static ContainerNode buildMyContainerNode(final Object keyLeafValue) {
- final LeafNode<?> ordinaryLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ordinaryLeaf))
- .withValue("test-value").build();
+ final LeafNode<?> ordinaryLeafNode = Builders.leafBuilder()
+ .withNodeIdentifier(new NodeIdentifier(ORDINARY_LEAF)).withValue("test-value").build();
- final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myList))
+ final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(myList, flags, keyLeafValue))
+ new NodeIdentifierWithPredicates(MY_LIST, FLAGS, keyLeafValue))
.withChild(ordinaryLeafNode).build()).build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer)).withChild(myListNode).build();
+ new NodeIdentifier(MY_CONTAINER)).withChild(myListNode).build();
return myContainerNode;
}
private static YangInstanceIdentifier buildPathToFlagsLeafNode(final Object keyLeafValue) {
final ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
- final ImmutableMap<QName, Object> keys = builder.put(flags, keyLeafValue).build();
+ final ImmutableMap<QName, Object> keys = builder.put(FLAGS, keyLeafValue).build();
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(myList)
- .node(new NodeIdentifierWithPredicates(myList, keys)).node(flags);
+ final YangInstanceIdentifier path = YangInstanceIdentifier.of(MY_LIST)
+ .node(new NodeIdentifierWithPredicates(MY_LIST, keys)).node(FLAGS);
return path;
}
}
import java.net.URI;
import java.util.Map;
import org.jaxen.Function;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
public class DerefXPathFunctionTest {
- private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
-
- private static QNameModule fooModule;
- private static QName myContainer;
- private static QName myInnerContainer;
- private static QName myList;
- private static QName keyLeafA;
- private static QName keyLeafB;
- private static QName iidLeaf;
- private static QName referencedLeaf;
- private static QName referencedLeafList;
- private static QName absLeafrefLeaf;
- private static QName relLeafrefLeaf;
- private static QName leafListLeafrefLeaf;
- private static QName ordinaryLeafA;
- private static QName ordinaryLeafB;
-
- @BeforeClass
- public static void setup() {
- jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
-
- fooModule = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
- myContainer = QName.create(fooModule, "my-container");
- myInnerContainer = QName.create(fooModule, "my-inner-container");
- myList = QName.create(fooModule, "my-list");
- keyLeafA = QName.create(fooModule, "key-leaf-a");
- keyLeafB = QName.create(fooModule, "key-leaf-b");
- iidLeaf = QName.create(fooModule, "iid-leaf");
- referencedLeaf = QName.create(fooModule, "referenced-leaf");
- referencedLeafList = QName.create(fooModule, "referenced-leaf-list");
- absLeafrefLeaf = QName.create(fooModule, "abs-leafref-leaf");
- relLeafrefLeaf = QName.create(fooModule, "rel-leafref-leaf");
- leafListLeafrefLeaf = QName.create(fooModule, "leaf-list-leafref-leaf");
- ordinaryLeafA = QName.create(fooModule, "ordinary-leaf-a");
- ordinaryLeafB = QName.create(fooModule, "ordinary-leaf-b");
- }
+ private static JaxenSchemaContextFactory jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
+
+ private static final QNameModule FOO_MODULE = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
+ private static final QName MY_CONTAINER = QName.create(FOO_MODULE, "my-container");
+ private static final QName MY_INNER_CONTAINER = QName.create(FOO_MODULE, "my-inner-container");
+ private static final QName MY_LIST = QName.create(FOO_MODULE, "my-list");
+ private static final QName KEY_LEAF_A = QName.create(FOO_MODULE, "key-leaf-a");
+ private static final QName KEY_LEAF_B = QName.create(FOO_MODULE, "key-leaf-b");
+ private static final QName IID_LEAF = QName.create(FOO_MODULE, "iid-leaf");
+ private static final QName REFERENCED_LEAF = QName.create(FOO_MODULE, "referenced-leaf");
+ private static final QName REFERENCED_LEAFLIST = QName.create(FOO_MODULE, "referenced-leaf-list");
+ private static final QName ABS_LEAFREF_LEAF = QName.create(FOO_MODULE, "abs-leafref-leaf");
+ private static final QName REL_LEAFREF_LEAF = QName.create(FOO_MODULE, "rel-leafref-leaf");
+ private static final QName LEAFLIST_LEAFREF_LEAF = QName.create(FOO_MODULE, "leaf-list-leafref-leaf");
+ private static final QName ORDINARY_LEAF_A = QName.create(FOO_MODULE, "ordinary-leaf-a");
+ private static final QName ORDINARY_LEAF_B = QName.create(FOO_MODULE, "ordinary-leaf-b");
@Test
public void testDerefFunctionForInstanceIdentifier() throws Exception {
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
final LeafNode<?> referencedLeafNode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(referencedLeaf)).withValue("referenced-leaf-node-value").build();
+ new NodeIdentifier(REFERENCED_LEAF)).withValue("referenced-leaf-node-value").build();
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNodeForIIdTest(
referencedLeafNode));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
final LeafNode<?> referencedLeafNode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(referencedLeaf)).withValue("referenced-leaf-node-value").build();
+ new NodeIdentifier(REFERENCED_LEAF)).withValue("referenced-leaf-node-value").build();
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNodeForLeafrefTest(
referencedLeafNode));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
- final YangInstanceIdentifier absLeafrefPath = YangInstanceIdentifier.of(myInnerContainer).node(absLeafrefLeaf);
+ final YangInstanceIdentifier absLeafrefPath = YangInstanceIdentifier.of(MY_INNER_CONTAINER)
+ .node(ABS_LEAFREF_LEAF);
NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(absLeafrefPath);
final Function derefFunction = normalizedNodeContextSupport.getFunctionContext()
assertTrue(derefResult instanceof NormalizedNode<?, ?>);
assertSame(referencedLeafNode, derefResult);
- final YangInstanceIdentifier relLeafrefPath = YangInstanceIdentifier.of(myInnerContainer).node(relLeafrefLeaf);
+ final YangInstanceIdentifier relLeafrefPath = YangInstanceIdentifier.of(MY_INNER_CONTAINER)
+ .node(REL_LEAFREF_LEAF);
normalizedNodeContext = normalizedNodeContextSupport.createContext(relLeafrefPath);
derefResult = derefFunction.call(normalizedNodeContext, ImmutableList.of());
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
final LeafSetNode<?> referencedLeafListNode = Builders.leafSetBuilder().withNodeIdentifier(
- new NodeIdentifier(referencedLeafList))
+ new NodeIdentifier(REFERENCED_LEAFLIST))
.withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
- new NodeWithValue<>(referencedLeafList, "referenced-node-entry-value-a"))
+ new NodeWithValue<>(REFERENCED_LEAFLIST, "referenced-node-entry-value-a"))
.withValue("referenced-node-entry-value-a").build())
.withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
- new NodeWithValue<>(referencedLeafList, "referenced-node-entry-value-b"))
+ new NodeWithValue<>(REFERENCED_LEAFLIST, "referenced-node-entry-value-b"))
.withValue("referenced-node-entry-value-b").build())
.withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
- new NodeWithValue<>(referencedLeafList, "referenced-node-entry-value-c"))
+ new NodeWithValue<>(REFERENCED_LEAFLIST, "referenced-node-entry-value-c"))
.withValue("referenced-node-entry-value-c").build())
.build();
referencedLeafListNode));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
- final YangInstanceIdentifier leafListLeafrefPath = YangInstanceIdentifier.of(myInnerContainer)
- .node(leafListLeafrefLeaf);
+ final YangInstanceIdentifier leafListLeafrefPath = YangInstanceIdentifier.of(MY_INNER_CONTAINER)
+ .node(LEAFLIST_LEAFREF_LEAF);
final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport
.createContext(leafListLeafrefPath);
assertTrue(derefResult instanceof NormalizedNode<?, ?>);
final LeafSetEntryNode<?> referencedLeafListNodeEntry = referencedLeafListNode.getChild(
- new NodeWithValue<>(referencedLeafList, "referenced-node-entry-value-b")).get();
+ new NodeWithValue<>(REFERENCED_LEAFLIST, "referenced-node-entry-value-b")).get();
assertSame(referencedLeafListNodeEntry, derefResult);
}
private static ContainerNode buildMyContainerNodeForIIdTest(final LeafNode<?> referencedLeafNode) {
- final Map<QName, Object> keyValues = ImmutableMap.of(keyLeafA, "key-value-a", keyLeafB, "key-value-b");
- final YangInstanceIdentifier iidPath = YangInstanceIdentifier.of(myContainer).node(myList)
- .node(new NodeIdentifierWithPredicates(myList, keyValues)).node(referencedLeaf);
+ final Map<QName, Object> keyValues = ImmutableMap.of(KEY_LEAF_A, "key-value-a", KEY_LEAF_B, "key-value-b");
+ final YangInstanceIdentifier iidPath = YangInstanceIdentifier.of(MY_CONTAINER).node(MY_LIST)
+ .node(new NodeIdentifierWithPredicates(MY_LIST, keyValues)).node(REFERENCED_LEAF);
- final LeafNode<?> iidLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(iidLeaf))
+ final LeafNode<?> iidLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(IID_LEAF))
.withValue(iidPath).build();
- final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myList))
+ final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(myList, keyValues))
+ new NodeIdentifierWithPredicates(MY_LIST, keyValues))
.withChild(iidLeafNode)
.withChild(referencedLeafNode).build())
.build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer)).withChild(myListNode).build();
+ new NodeIdentifier(MY_CONTAINER)).withChild(myListNode).build();
return myContainerNode;
}
private static YangInstanceIdentifier buildPathToIIdLeafNode() {
- final Map<QName, Object> keyValues = ImmutableMap.of(keyLeafA, "key-value-a", keyLeafB, "key-value-b");
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(myList)
- .node(new NodeIdentifierWithPredicates(myList, keyValues)).node(iidLeaf);
+ final Map<QName, Object> keyValues = ImmutableMap.of(KEY_LEAF_A, "key-value-a", KEY_LEAF_B, "key-value-b");
+ final YangInstanceIdentifier path = YangInstanceIdentifier.of(MY_LIST)
+ .node(new NodeIdentifierWithPredicates(MY_LIST, keyValues)).node(IID_LEAF);
return path;
}
// variant for a leafref that references a leaf
private static ContainerNode buildMyContainerNodeForLeafrefTest(final LeafNode<?> referencedLeafNode) {
- final Map<QName, Object> keyValues = ImmutableMap.of(keyLeafA, "value-a", keyLeafB, "value-b");
+ final Map<QName, Object> keyValues = ImmutableMap.of(KEY_LEAF_A, "value-a", KEY_LEAF_B, "value-b");
- final LeafNode<?> absLeafrefNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(absLeafrefLeaf))
+ final LeafNode<?> absLeafrefNode = Builders.leafBuilder()
+ .withNodeIdentifier(new NodeIdentifier(ABS_LEAFREF_LEAF))
.withValue("referenced-leaf-node-value").build();
- final LeafNode<?> relLeafrefNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(relLeafrefLeaf))
+ final LeafNode<?> relLeafrefNode = Builders.leafBuilder()
+ .withNodeIdentifier(new NodeIdentifier(REL_LEAFREF_LEAF))
.withValue("referenced-leaf-node-value").build();
final LeafNode<?> ordinaryLeafANode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(ordinaryLeafA)).withValue("value-a").build();
+ new NodeIdentifier(ORDINARY_LEAF_A)).withValue("value-a").build();
final LeafNode<?> ordinaryLeafBNode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(ordinaryLeafB)).withValue("value-b").build();
+ new NodeIdentifier(ORDINARY_LEAF_B)).withValue("value-b").build();
- final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myList))
+ final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(myList, keyValues))
+ new NodeIdentifierWithPredicates(MY_LIST, keyValues))
.withChild(referencedLeafNode).build())
.build();
final ContainerNode myInnerContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myInnerContainer))
+ new NodeIdentifier(MY_INNER_CONTAINER))
.withChild(absLeafrefNode)
.withChild(relLeafrefNode)
.withChild(ordinaryLeafANode)
.withChild(ordinaryLeafBNode).build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer))
+ new NodeIdentifier(MY_CONTAINER))
.withChild(myListNode)
.withChild(myInnerContainerNode).build();
return myContainerNode;
// variant for a leafref that references a leaf-list
private static ContainerNode buildMyContainerNodeForLeafrefTest(final LeafSetNode<?> referencedLeafListNode) {
final LeafNode<?> leafListLeafrefNode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(leafListLeafrefLeaf)).withValue("referenced-node-entry-value-b").build();
+ new NodeIdentifier(LEAFLIST_LEAFREF_LEAF)).withValue("referenced-node-entry-value-b").build();
final LeafNode<?> ordinaryLeafANode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(ordinaryLeafA)).withValue("value-a").build();
+ new NodeIdentifier(ORDINARY_LEAF_A)).withValue("value-a").build();
final LeafNode<?> ordinaryLeafBNode = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(ordinaryLeafB)).withValue("value-b").build();
+ new NodeIdentifier(ORDINARY_LEAF_B)).withValue("value-b").build();
final ContainerNode myInnerContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myInnerContainer))
+ new NodeIdentifier(MY_INNER_CONTAINER))
.withChild(leafListLeafrefNode)
.withChild(ordinaryLeafANode)
.withChild(ordinaryLeafBNode).build();
- final Map<QName, Object> keyValues = ImmutableMap.of(keyLeafA, "value-a", keyLeafB, "value-b");
+ final Map<QName, Object> keyValues = ImmutableMap.of(KEY_LEAF_A, "value-a", KEY_LEAF_B, "value-b");
- final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myList))
+ final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(myList, keyValues))
+ new NodeIdentifierWithPredicates(MY_LIST, keyValues))
.withChild(referencedLeafListNode).build())
.build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer))
+ new NodeIdentifier(MY_CONTAINER))
.withChild(myListNode)
.withChild(myInnerContainerNode).build();
return myContainerNode;
* 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.yangtools.yang.data.jaxen;
import static org.junit.Assert.assertEquals;
import org.jaxen.Context;
import org.jaxen.Function;
import org.jaxen.FunctionCallException;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
public class DerivedFromXPathFunctionTest {
- private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
-
- private static QNameModule barModule;
- private static QName myContainer;
- private static QName myList;
- private static QName keyLeaf;
- private static QName idrefLeaf;
- private static QName idC2Identity;
-
- @BeforeClass
- public static void setup() {
- jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
-
- barModule = QNameModule.create(URI.create("bar-ns"), Revision.of("2017-04-03"));
- myContainer = QName.create(barModule, "my-container");
- myList = QName.create(barModule, "my-list");
- keyLeaf = QName.create(barModule, "key-leaf");
- idrefLeaf = QName.create(barModule, "idref-leaf");
- idC2Identity = QName.create(barModule, "id-c2");
- }
+ private static final JaxenSchemaContextFactory SCHEMA_CONTEXT_FACTORY = new JaxenSchemaContextFactory();
+ private static final QNameModule BAR_MODULE = QNameModule.create(URI.create("bar-ns"), Revision.of("2017-04-03"));
+ private static final QName MY_CONTAINER = QName.create(BAR_MODULE, "my-container");
+ private static final QName MY_LIST = QName.create(BAR_MODULE, "my-list");
+ private static final QName KEY_LEAF = QName.create(BAR_MODULE, "key-leaf");
+ private static final QName IDREF_LEAF = QName.create(BAR_MODULE, "idref-leaf");
+ private static final QName ID_C2_IDENTITY = QName.create(BAR_MODULE, "id-c2");
@Test
public void testDerivedFromFunction() throws Exception {
"/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/derived-from-function/bar-invalid.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("should be QName"));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("bar-prefix", barModule);
+ converterBiMap.put("bar-prefix", BAR_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
}
private static ContainerNode buildMyContainerNode(final Object idrefLeafValue) {
- final LeafNode<?> idrefLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(idrefLeaf))
+ final LeafNode<?> idrefLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(IDREF_LEAF))
.withValue(idrefLeafValue).build();
- final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myList))
+ final MapNode myListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(myList, keyLeaf, "key-value"))
+ new NodeIdentifierWithPredicates(MY_LIST, KEY_LEAF, "key-value"))
.withChild(idrefLeafNode).build()).build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer)).withChild(myListNode).build();
+ new NodeIdentifier(MY_CONTAINER)).withChild(myListNode).build();
return myContainerNode;
}
private static YangInstanceIdentifier buildPathToIdrefLeafNode() {
final ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
- final ImmutableMap<QName, Object> keys = builder.put(keyLeaf, "key-value").build();
+ final ImmutableMap<QName, Object> keys = builder.put(KEY_LEAF, "key-value").build();
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(myList)
- .node(new NodeIdentifierWithPredicates(myList, keys)).node(idrefLeaf);
+ final YangInstanceIdentifier path = YangInstanceIdentifier.of(MY_LIST)
+ .node(new NodeIdentifierWithPredicates(MY_LIST, keys)).node(IDREF_LEAF);
return path;
}
}
* 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.yangtools.yang.data.jaxen;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.net.URI;
-import java.text.ParseException;
import org.jaxen.Context;
import org.jaxen.Function;
import org.jaxen.FunctionCallException;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
public class EnumValueXPathFunctionTest {
- private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
-
- private static QNameModule fooModule;
- private static QName myContainer;
- private static QName alarm;
- private static QName severity;
- private static QName ordinaryLeaf;
-
- @BeforeClass
- public static void setup() throws ParseException {
- jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
-
- fooModule = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
- myContainer = QName.create(fooModule, "my-container");
- alarm = QName.create(fooModule, "alarm");
- severity = QName.create(fooModule, "severity");
- ordinaryLeaf = QName.create(fooModule, "ordinary-leaf");
- }
+ private static final JaxenSchemaContextFactory SCHEMA_CONTEXT_FACTORY = new JaxenSchemaContextFactory();
+ private static final QNameModule FOO_MODULE = QNameModule.create(URI.create("foo-ns"), Revision.of("2017-04-03"));
+ private static final QName MY_CONTAINER = QName.create(FOO_MODULE, "my-container");
+ private static final QName ALARM = QName.create(FOO_MODULE, "alarm");
+ private static final QName SEVERITY = QName.create(FOO_MODULE, "severity");
+ private static final QName ORDINARY_LEAF = QName.create(FOO_MODULE, "ordinary-leaf");
@Test
public void testEnumValueFunction() throws Exception {
"/yang-xpath-functions-test/enum-value-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("major"));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/enum-value-function/foo-invalid.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("major"));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/enum-value-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(100));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
"/yang-xpath-functions-test/enum-value-function/foo.yang");
assertNotNull(schemaContext);
- final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
+ final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("unknown"));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
- converterBiMap.put("foo-prefix", fooModule);
+ converterBiMap.put("foo-prefix", FOO_MODULE);
final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
(JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));
}
private static ContainerNode buildMyContainerNode(final Object keyLeafValue) {
- final LeafNode<?> ordinaryLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ordinaryLeaf))
- .withValue("test-value").build();
+ final LeafNode<?> ordinaryLeafNode = Builders.leafBuilder()
+ .withNodeIdentifier(new NodeIdentifier(ORDINARY_LEAF)).withValue("test-value").build();
- final MapNode alarmListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(alarm))
+ final MapNode alarmListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(ALARM))
.withChild(Builders.mapEntryBuilder().withNodeIdentifier(
- new NodeIdentifierWithPredicates(alarm, severity, keyLeafValue))
+ new NodeIdentifierWithPredicates(ALARM, SEVERITY, keyLeafValue))
.withChild(ordinaryLeafNode).build()).build();
final ContainerNode myContainerNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(myContainer)).withChild(alarmListNode).build();
+ new NodeIdentifier(MY_CONTAINER)).withChild(alarmListNode).build();
return myContainerNode;
}
private static YangInstanceIdentifier buildPathToSeverityLeafNode(final Object keyLeafValue) {
final ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
- final ImmutableMap<QName, Object> keys = builder.put(severity, keyLeafValue).build();
+ final ImmutableMap<QName, Object> keys = builder.put(SEVERITY, keyLeafValue).build();
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(alarm)
- .node(new NodeIdentifierWithPredicates(alarm, keys)).node(severity);
+ final YangInstanceIdentifier path = YangInstanceIdentifier.of(ALARM)
+ .node(new NodeIdentifierWithPredicates(ALARM, keys)).node(SEVERITY);
return path;
}
}
\ No newline at end of file
import com.google.common.collect.SetMultimap;
import com.google.common.util.concurrent.ListenableFuture;
import java.net.URI;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
private static final URI FOO_NS = URI.create("foo-ns");
private static final URI BAR_NS = URI.create("bar-ns");
private static final URI BAZ_NS = URI.create("baz-ns");
- private static Revision revision;
- private static QNameModule foo;
- private static QName myFooContA;
- private static QName myFooContB;
- private static QName myFooContC;
- private static QNameModule bar;
- private static QName myBarContA;
- private static QName myBarContB;
- private static QNameModule baz;
-
- @BeforeClass
- public static void setup() throws ParseException {
- revision = Revision.of("2017-05-16");
- foo = QNameModule.create(FOO_NS, revision);
- myFooContA = QName.create(foo, "my-foo-cont-a");
- myFooContB = QName.create(foo, "my-foo-cont-b");
- myFooContC = QName.create(foo, "my-foo-cont-c");
- bar = QNameModule.create(BAR_NS, revision);
- myBarContA = QName.create(bar, "my-bar-cont-a");
- myBarContB = QName.create(bar, "my-bar-cont-b");
- baz = QNameModule.create(BAZ_NS, revision);
- }
+ private static final Revision REVISION = Revision.of("2017-05-16");
+ private static final QNameModule FOO_MODULE = QNameModule.create(FOO_NS, REVISION);
+ private static final QName MY_FOO_CONT_A = QName.create(FOO_MODULE, "my-foo-cont-a");
+ private static final QName MY_FOO_CONT_B = QName.create(FOO_MODULE, "my-foo-cont-b");
+ private static final QName MY_FOO_CONT_C = QName.create(FOO_MODULE, "my-foo-cont-c");
+ private static final QNameModule BAR_MODULE = QNameModule.create(BAR_NS, REVISION);
+ private static final QName MY_BAR_CONT_A = QName.create(BAR_MODULE, "my-bar-cont-a");
+ private static final QName MY_BAR_CONT_B = QName.create(BAR_MODULE, "my-bar-cont-b");
+ private static final QNameModule BAZ_MODULE = QNameModule.create(BAZ_NS, REVISION);
@Test
public void testDeviationsSupportedInSomeModules() throws Exception {
final SetMultimap<QNameModule, QNameModule> modulesWithSupportedDeviations =
ImmutableSetMultimap.<QNameModule, QNameModule>builder()
- .put(foo, bar)
- .put(foo, baz)
- .put(bar, baz)
+ .put(FOO_MODULE, BAR_MODULE)
+ .put(FOO_MODULE, BAZ_MODULE)
+ .put(BAR_MODULE, BAZ_MODULE)
.build();
final ListenableFuture<SchemaContext> lf = createSchemaContext(modulesWithSupportedDeviations, FOO, BAR, BAZ,
final SchemaContext schemaContext = lf.get();
assertNotNull(schemaContext);
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test
final SchemaContext schemaContext = lf.get();
assertNotNull(schemaContext);
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test
final SchemaContext schemaContext = lf.get();
assertNotNull(schemaContext);
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.SetMultimap;
import java.net.URI;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
private static final URI BAZ_NS = URI.create("baz-ns");
private static final Revision REVISION = Revision.of("2017-05-16");
- private static QNameModule foo;
- private static QName myFooContA;
- private static QName myFooContB;
- private static QName myFooContC;
- private static QNameModule bar;
- private static QName myBarContA;
- private static QName myBarContB;
- private static QNameModule baz;
- private static QName myBazCont;
-
- @BeforeClass
- public static void setup() {
- foo = QNameModule.create(FOO_NS, REVISION);
- myFooContA = QName.create(foo, "my-foo-cont-a");
- myFooContB = QName.create(foo, "my-foo-cont-b");
- myFooContC = QName.create(foo, "my-foo-cont-c");
- bar = QNameModule.create(BAR_NS, REVISION);
- myBarContA = QName.create(bar, "my-bar-cont-a");
- myBarContB = QName.create(bar, "my-bar-cont-b");
- baz = QNameModule.create(BAZ_NS, REVISION);
- myBazCont = QName.create(baz, "my-baz-cont");
- }
+ private static final QNameModule FOO = QNameModule.create(FOO_NS, REVISION);
+ private static final QName MY_FOO_CONT_A = QName.create(FOO, "my-foo-cont-a");
+ private static final QName MY_FOO_CONT_B = QName.create(FOO, "my-foo-cont-b");
+ private static final QName MY_FOO_CONT_C = QName.create(FOO, "my-foo-cont-c");
+ private static final QNameModule BAR = QNameModule.create(BAR_NS, REVISION);
+ private static final QName MY_BAR_CONT_A = QName.create(BAR, "my-bar-cont-a");
+ private static final QName MY_BAR_CONT_B = QName.create(BAR, "my-bar-cont-b");
+ private static final QNameModule BAZ = QNameModule.create(BAZ_NS, REVISION);
+ private static final QName MY_BAZ_CONT = QName.create(BAZ, "my-baz-cont");
@Test
public void testDeviationsSupportedInSomeModules() throws Exception {
final SetMultimap<QNameModule, QNameModule> modulesWithSupportedDeviations =
ImmutableSetMultimap.<QNameModule, QNameModule>builder()
- .put(foo, bar)
- .put(foo, baz)
- .put(bar, baz)
+ .put(FOO, BAR)
+ .put(FOO, BAZ)
+ .put(BAR, BAZ)
.build();
final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
.buildEffective();
assertNotNull(schemaContext);
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test
.buildEffective();
assertNotNull(schemaContext);
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test
.buildEffective();
assertNotNull(schemaContext);
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
- assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_B)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_FOO_CONT_C)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_A)));
+ assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, MY_BAR_CONT_B)));
}
@Test