use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestXmlBodyReaderMountPoint method moduleSubContainerDataPostTest.
@Test
public void moduleSubContainerDataPostTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
mockBodyReader(uri, this.xmlBodyReader, true);
final InputStream inputStream = TestXmlBodyReaderMountPoint.class.getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkMountPointNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestJsonBodyReader method moduleSubContainerDataPostTest.
@Test
public void moduleSubContainerDataPostTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1");
final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
final String uri = "instance-identifier-module:cont";
mockBodyReader(uri, this.jsonBodyReader, true);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.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 TestJsonBodyReader method rpcModuleInputTest.
@Test
public void rpcModuleInputTest() throws Exception {
final String uri = "invoke-rpc-module:rpc-test";
mockBodyReader(uri, this.jsonBodyReader, true);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/invoke-rpc/json/rpc-input.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkNormalizedNodeContext(returnValue);
final ContainerNode inputNode = (ContainerNode) returnValue.getData();
final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(inputNode.getIdentifier().getNodeType(), "cont"));
final Optional<DataContainerChild> contDataNode = inputNode.findChildByArg(yangCont.getLastPathArgument());
assertTrue(contDataNode.isPresent());
assertTrue(contDataNode.get() instanceof ContainerNode);
final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(inputNode.getIdentifier().getNodeType(), "lf"));
final Optional<DataContainerChild> leafDataNode = ((ContainerNode) contDataNode.get()).findChildByArg(yangleaf.getLastPathArgument());
assertTrue(leafDataNode.isPresent());
assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().body().toString()));
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestJsonBodyReader 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.jsonBodyReader, false);
final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsondata.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.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 TestJsonBodyReader method moduleSubContainerChoiceAugmentDataPostTest.
// FIXME: Uncomment this when JsonParserStream works correctly with case augmentation with choice
// @Test
public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final Module augmentModule = schemaContext.findModules(XMLNamespace.of("augment:module")).iterator().next();
final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
final YangInstanceIdentifier.AugmentationIdentifier augChoice1II = new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName));
final YangInstanceIdentifier.AugmentationIdentifier augChoice2II = new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName));
final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName).node(containerQName);
final String uri = "instance-identifier-module:cont";
mockBodyReader(uri, this.jsonBodyReader, true);
final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/json/json_augment_choice_container.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
}
Aggregations