use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestXmlBodyReader method moduleDataTest.
@Test
public void moduleDataTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
final String uri = "instance-identifier-module:cont";
mockBodyReader(uri, this.xmlBodyReader, false);
final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class NnToXmlTest method nnAsYangUint32ToXmlTest.
@Test
public void nnAsYangUint32ToXmlTest() throws Exception {
final String elName = "lfUint32";
final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.uint32Type()).deserialize("4123456789"), elName);
nnToXml(normalizedNodeContext, "<" + elName + ">4123456789</" + elName + ">");
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class NnToXmlTest method nnAsYangInt32ToXmlTest.
@Test
public void nnAsYangInt32ToXmlTest() throws Exception {
final String elName = "lfInt32";
final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.int32Type()).deserialize("201234"), elName);
nnToXml(normalizedNodeContext, "<" + elName + ">201234</" + elName + ">");
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class NnToXmlTest method prepareIdrefData.
private static NormalizedNodeContext prepareIdrefData(final String prefix, final boolean valueAsQName) {
final QName cont = QName.create("basic:module", "2013-12-02", "cont");
final QName cont1 = QName.create("basic:module", "2013-12-02", "cont1");
final QName lf11 = QName.create("basic:module", "2013-12-02", "lf11");
final YangInstanceIdentifier yII = YangInstanceIdentifier.builder().node(cont).build();
final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) contSchema);
final DataSchemaNode cont1Schema = ((ContainerSchemaNode) contSchema).getDataChildByName(cont1);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> cont1Data = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) cont1Schema);
Object value = null;
if (valueAsQName) {
value = QName.create("referenced:module", "2013-12-02", "iden");
} else {
value = "no qname value";
}
final List<DataSchemaNode> instanceLf = ControllerContext.findInstanceDataChildrenByName((DataNodeContainer) cont1Schema, lf11.getLocalName());
final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null);
cont1Data.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(value).build());
contData.withChild(cont1Data.build());
final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(new InstanceIdentifierContext<>(yII, contSchema, null, schemaContext), contData.build());
return testNormalizedNodeContext;
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class NnToXmlTest method snAsYangUint64ToXmlTest.
@Test
public void snAsYangUint64ToXmlTest() throws Exception {
final String elName = "lfUint64";
final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.uint64Type()).deserialize("5123456789"), elName);
nnToXml(normalizedNodeContext, "<" + elName + ">5123456789</" + elName + ">");
}
Aggregations