本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.SchemaPath.create方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaPath.create方法的具体用法?Java SchemaPath.create怎么用?Java SchemaPath.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.api.SchemaPath
的用法示例。
在下文中一共展示了SchemaPath.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug7246/yang/rpc-test.yang");
final JsonParser parser = new JsonParser();
final JsonElement expextedJson = parser
.parse(new FileReader(new File(getClass().getResource("/bug7246/json/expected-output.json").toURI())));
final DataContainerChild<? extends PathArgument, ?> inputStructure = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(qN("my-name")))
.withChild(ImmutableNodes.leafNode(new NodeIdentifier(qN("my-name")), "my-value")).build();
final SchemaPath rootPath = SchemaPath.create(true, qN("my-name"), qN("input"));
final Writer writer = new StringWriter();
final String jsonOutput = normalizedNodeToJsonStreamTransformation(schemaContext, rootPath, writer,
inputStructure);
final JsonElement serializedJson = parser.parse(jsonOutput);
assertEquals(expextedJson, serializedJson);
}
示例2: findNodeInSchemaContextTheSameNameOfSiblingsTest
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void findNodeInSchemaContextTheSameNameOfSiblingsTest() throws URISyntaxException, IOException,
YangSyntaxErrorException, ReactorException {
final SchemaContext context = TestUtils.parseYangSources("/schema-context-util-test");
final Module myModule = context.findModule(new URI("uri:my-module"), Revision.of("2014-10-07")).get();
final ChoiceSchemaNode choice = (ChoiceSchemaNode) getRpcByName(myModule, "my-name").getInput()
.getDataChildByName(QName.create(myModule.getQNameModule(), "my-choice"));
final SchemaNode testNode = choice.findCaseNodes("case-two").iterator().next()
.getDataChildByName(QName.create(myModule.getQNameModule(), "two"));
final SchemaPath path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-name"),
QName.create(myModule.getQNameModule(), "input"), QName.create(myModule.getQNameModule(), "my-choice"),
QName.create(myModule.getQNameModule(), "case-two"), QName.create(myModule.getQNameModule(), "two"));
final SchemaNode foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());
assertNotNull(testNode);
assertNotNull(foundNode);
assertEquals(testNode, foundNode);
}
示例3: testDeviation
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void testDeviation() throws ReactorException {
final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
.addSource(sourceForResource("/model/bar.yang"))
.addSource(sourceForResource("/context-test/deviation-test.yang"))
.buildEffective();
final Module testModule = context.findModule("deviation-test", Revision.of("2013-02-27")).get();
final Set<Deviation> deviations = testModule.getDeviations();
assertEquals(1, deviations.size());
final Deviation dev = deviations.iterator().next();
assertEquals(Optional.of("system/user ref"), dev.getReference());
final URI expectedNS = URI.create("urn:opendaylight.bar");
final Revision expectedRev = Revision.of("2013-07-03");
final List<QName> path = new ArrayList<>();
path.add(QName.create(expectedNS, expectedRev, "interfaces"));
path.add(QName.create(expectedNS, expectedRev, "ifEntry"));
final SchemaPath expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, dev.getTargetPath());
assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
}
示例4: createSchemaPathList
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
private static List<SchemaPath> createSchemaPathList() {
final QName qname1 = QName.create("urn:odl:xxx", "2015-01-01", "localName");
final QName qname2 = QName.create("urn:odl:yyy", "2015-01-01", "localName");
final SchemaPath path1 = SchemaPath.create(true, qname1);
final SchemaPath path2 = SchemaPath.create(true, qname2);
return Arrays.asList(path1, path2);
}
示例5: readSchemaPath
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Override
public SchemaPath readSchemaPath() throws IOException {
readSignatureMarkerAndVersionIfNeeded();
final boolean absolute = input.readBoolean();
final int size = input.readInt();
final Collection<QName> qnames = new ArrayList<>(size);
for (int i = 0; i < size; ++i) {
qnames.add(readQName());
}
return SchemaPath.create(qnames, absolute);
}
示例6: testSchemaPathSerialization
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void testSchemaPathSerialization() throws Exception {
final SchemaPath expected = SchemaPath.create(true, TestModel.ANY_XML_QNAME);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));
nnout.writeSchemaPath(expected);
NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
bos.toByteArray()));
SchemaPath actual = nnin.readSchemaPath();
assertEquals(expected, actual);
}
示例7: registerNotificationListener
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Override
public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
final Class<T> type, final NotificationListener<T> listener) {
final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
@Override
protected void removeRegistration() {
domReg.close();
}
};
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:16,代码来源:HeliumNotificationProviderServiceWithInterestListeners.java
示例8: jsonStringFromDataObject
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
/**
* Converts a {@link DataObject} to a JSON representation in a string using the relevant YANG
* schema if it is present. This defaults to using a {@link org.opendaylight.yangtools.yang.model.api.SchemaContextListener} if running an
* OSGi environment or {@link BindingReflections#loadModuleInfos()} if run while not in an OSGi
* environment or if the schema isn't available via {@link org.opendaylight.yangtools.yang.model.api.SchemaContextListener}.
*
* @param path {@literal InstanceIdentifier<?>}
* @param object DataObject
* @param pretty boolean
* @return String
*/
public final String jsonStringFromDataObject(final InstanceIdentifier<?> path, final DataObject object, final boolean pretty) {
final SchemaPath scPath = SchemaPath.create(FluentIterable.from(path.getPathArguments()).transform(new Function<PathArgument, QName>() {
@Override
public QName apply(final PathArgument input) {
return BindingReflections.findQName(input.getType());
}
}), true);
final Writer writer = new StringWriter();
final NormalizedNodeStreamWriter domWriter;
if(pretty) {
domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.create(this.context), scPath.getParent(), scPath.getLastComponent().getNamespace(), JsonWriterFactory.createJsonWriter(writer,2));
} else {
domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.create(this.context), scPath.getParent(), scPath.getLastComponent().getNamespace(), JsonWriterFactory.createJsonWriter(writer));
}
final BindingStreamEventWriter bindingWriter = this.codecRegistry.newWriter(path, domWriter);
try {
this.codecRegistry.getSerializer(path.getTargetType()).serialize(object, bindingWriter);
} catch (final IOException e) {
throw new IllegalStateException(e);
}
return writer.toString();
}
示例9: setUp
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
final SchemaPath schemaPath = SchemaPath.create(true,
NetworkInstances.QNAME, NetworkInstance.QNAME, Protocols.QNAME);
doReturn(schemaPath).when(this.processor).getSchemaPath();
doReturn("processor").when(this.processor).toString();
}
示例10: testRequireInstanceSubstatement
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void testRequireInstanceSubstatement() {
final SchemaPath schemaPath = SchemaPath.create(true, QName.create("test", "my-cont"),
QName.create("test", "my-leafref"));
final RevisionAwareXPathImpl path = new RevisionAwareXPathImpl("../my-leaf", false);
LeafrefTypeBuilder leafrefTypeBuilder = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(path);
leafrefTypeBuilder.setRequireInstance(false);
LeafrefTypeDefinition leafref = leafrefTypeBuilder.build();
assertFalse(leafref.requireInstance());
leafrefTypeBuilder.setRequireInstance(true);
leafref = leafrefTypeBuilder.build();
assertTrue(leafref.requireInstance());
leafrefTypeBuilder.setRequireInstance(true);
leafref = leafrefTypeBuilder.build();
assertTrue(leafref.requireInstance());
try {
leafrefTypeBuilder.setRequireInstance(false);
fail("An IllegalArgumentException should have been thrown.");
} catch (IllegalArgumentException ex) {
assertEquals(
"Cannot switch off require-instance in type AbsoluteSchemaPath{path=[(test)my-cont, (test)my-leafref]}",
ex.getMessage());
}
}
示例11: testFindDummyData
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void testFindDummyData() {
MockitoAnnotations.initMocks(this);
doReturn(Optional.empty()).when(mockSchemaContext).findModule(any(QNameModule.class));
doReturn("test").when(mockModule).getPrefix();
doReturn(NAMESPACE).when(mockModule).getNamespace();
doReturn(QNameModule.create(NAMESPACE)).when(mockModule).getQNameModule();
doReturn(Optional.empty()).when(mockModule).getRevision();
QName qname = QName.create("namespace", "localname");
SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qname), true);
assertEquals("Should be null. Module TestQName not found", null,
SchemaContextUtil.findDataSchemaNode(mockSchemaContext, schemaPath));
RevisionAwareXPath xpath = new RevisionAwareXPathImpl("/test:bookstore/test:book/test:title", true);
assertEquals("Should be null. Module bookstore not found", null,
SchemaContextUtil.findDataSchemaNode(mockSchemaContext, mockModule, xpath));
SchemaNode schemaNode = BaseTypes.int32Type();
RevisionAwareXPath xpathRelative = new RevisionAwareXPathImpl("../prefix", false);
assertEquals("Should be null, Module prefix not found", null,
SchemaContextUtil.findDataSchemaNodeForRelativeXPath(
mockSchemaContext, mockModule, schemaNode, xpathRelative));
assertEquals("Should be null. Module TestQName not found", null,
SchemaContextUtil.findNodeInSchemaContext(mockSchemaContext, Collections.singleton(qname)));
assertEquals("Should be null.", null, SchemaContextUtil.findParentModule(mockSchemaContext, schemaNode));
}
示例12: invalidBitDefinitionExceptionTest
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test(expected = InvalidBitDefinitionException.class)
public void invalidBitDefinitionExceptionTest() {
final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(SCHEMA_PATH);
final QName qName = QName.create("test.namespace.1", "2016-01-02", "test-name-1");
final SchemaPath schemaPath = SchemaPath.create(true, qName);
bitsTypeBuilder.addBit(BIT_A);
bitsTypeBuilder.addBit(BitBuilder.create(schemaPath, 55L).build());
bitsTypeBuilder.build();
}
示例13: test
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5437");
assertNotNull(context);
QName root = QName.create(NS, REV, "root");
QName leafRef2 = QName.create(NS, REV, "leaf-ref-2");
QName conGrp = QName.create(NS, REV, "con-grp");
QName leafRef = QName.create(NS, REV, "leaf-ref");
SchemaPath leafRefPath = SchemaPath.create(true, root, conGrp, leafRef);
SchemaPath leafRef2Path = SchemaPath.create(true, root, leafRef2);
SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, leafRefPath);
SchemaNode findDataSchemaNode2 = SchemaContextUtil.findDataSchemaNode(context, leafRef2Path);
assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
assertTrue(findDataSchemaNode2 instanceof LeafSchemaNode);
LeafSchemaNode leafRefNode = (LeafSchemaNode) findDataSchemaNode;
LeafSchemaNode leafRefNode2 = (LeafSchemaNode) findDataSchemaNode2;
assertTrue(leafRefNode.getType() instanceof LeafrefTypeDefinition);
assertTrue(leafRefNode2.getType() instanceof LeafrefTypeDefinition);
TypeDefinition<?> baseTypeForLeafRef = SchemaContextUtil.getBaseTypeForLeafRef(
(LeafrefTypeDefinition) leafRefNode.getType(), context, leafRefNode);
TypeDefinition<?> baseTypeForLeafRef2 = SchemaContextUtil.getBaseTypeForLeafRef(
(LeafrefTypeDefinition) leafRefNode2.getType(), context, leafRefNode2);
assertTrue(baseTypeForLeafRef instanceof BinaryTypeDefinition);
assertTrue(baseTypeForLeafRef2 instanceof Int16TypeDefinition);
}
示例14: canCreateBitsType
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
@Test
public void canCreateBitsType() {
MockitoAnnotations.initMocks(this);
doReturn("test").when(bit).getName();
QName qname = QName.create("namespace", "localname");
SchemaPath schemaPath = SchemaPath.create(true, qname);
BitsTypeDefinition bitsType = BaseTypes.bitsTypeBuilder(schemaPath).addBit(bit).build();
assertFalse(bitsType.getDescription().isPresent());
assertEquals("QName", qname, bitsType.getQName());
assertEquals(Optional.empty(), bitsType.getUnits());
assertNotEquals("Description should not be null", null, bitsType.toString());
assertFalse(bitsType.getReference().isPresent());
assertNull("BaseType should be null", bitsType.getBaseType());
assertEquals(Optional.empty(), bitsType.getDefaultValue());
assertEquals("getPath should equal schemaPath", schemaPath, bitsType.getPath());
assertEquals("Status should be CURRENT", Status.CURRENT, bitsType.getStatus());
assertEquals("Should be empty list", Collections.EMPTY_LIST, bitsType.getUnknownSchemaNodes());
assertEquals("Values should be [enumPair]", Collections.singletonList(bit), bitsType.getBits());
assertEquals("Hash code of bitsType should be equal",
bitsType.hashCode(), bitsType.hashCode());
assertNotEquals("bitsType shouldn't equal to null", null, bitsType);
assertEquals("bitsType should equals to itself", bitsType, bitsType);
assertNotEquals("bitsType shouldn't equal to object of other type", "str", bitsType);
}
示例15: createPath
import org.opendaylight.yangtools.yang.model.api.SchemaPath; //导入方法依赖的package包/类
public static SchemaPath createPath(final boolean absolute, final QNameModule module, final String... names) {
List<QName> path = new ArrayList<>(names.length);
for (String name : names) {
path.add(QName.create(module, name));
}
return SchemaPath.create(path, absolute);
}