use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfMessageTransformerTest method getWholeListsUsingFieldsTest.
@Test
public void getWholeListsUsingFieldsTest() throws IOException, SAXException {
// preparation of the fields
final YangInstanceIdentifier parentYiid = YangInstanceIdentifier.create(toId(NetconfState.QNAME));
final YangInstanceIdentifier datastoreListField = YangInstanceIdentifier.create(toId(Datastores.QNAME), toId(Datastore.QNAME), NodeIdentifierWithPredicates.of(Datastore.QNAME));
final YangInstanceIdentifier sessionListField = YangInstanceIdentifier.create(toId(Sessions.QNAME), toId(Session.QNAME), NodeIdentifierWithPredicates.of(Session.QNAME));
// building filter structure and NETCONF message
final AnyxmlNode<?> filterStructure = toFilterStructure(List.of(FieldsFilter.of(parentYiid, List.of(datastoreListField, sessionListField))), SCHEMA);
final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NETCONF_GET_QNAME, NetconfMessageTransformUtil.wrap(toId(NETCONF_GET_QNAME), filterStructure));
// testing
assertSimilarXml(netconfMessage, "<rpc message-id=\"m-0\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + "<get>\n" + "<filter xmlns:ns0=\"urn:ietf:params:xml:ns:netconf:base:1.0\" ns0:type=\"subtree\">\n" + "<netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n" + "<datastores>\n" + "<datastore/>\n" + "</datastores>\n" + "<sessions>\n" + "<session/>\n" + "</sessions>\n" + "</netconf-state>\n" + "</filter>\n" + "</get>\n" + "</rpc>");
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfMessageTransformerTest method toActionRequestChoiceTest.
@Test
public void toActionRequestChoiceTest() {
List<PathArgument> nodeIdentifiers = new ArrayList<>();
nodeIdentifiers.add(NodeIdentifier.create(CONFLICT_CHOICE_QNAME));
nodeIdentifiers.add(NodeIdentifier.create(CHOICE_CONT_QNAME));
DOMDataTreeIdentifier domDataTreeIdentifier = prepareDataTreeId(nodeIdentifiers);
NormalizedNode payload = initEmptyInputAction(CHOICE_ACTION_QNAME);
NetconfMessage actionRequest = actionNetconfMessageTransformer.toActionRequest(CHOICE_ACTION_PATH, domDataTreeIdentifier, payload);
Node childAction = checkBasePartOfActionRequest(actionRequest);
Node childChoiceCont = childAction.getFirstChild();
checkNode(childChoiceCont, "choice-cont", "choice-cont", URN_EXAMPLE_CONFLICT);
Node action = childChoiceCont.getLastChild();
checkNode(action, CHOICE_ACTION_QNAME.getLocalName(), CHOICE_ACTION_QNAME.getLocalName(), CHOICE_ACTION_QNAME.getNamespace().toString());
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfMessageTransformerTest method testCreateSubscriberNotificationSchemaNotPresent.
@Test
public void testCreateSubscriberNotificationSchemaNotPresent() throws Exception {
final NetconfMessageTransformer transformer = new NetconfMessageTransformer(new EmptyMountPointContext(SCHEMA), true, BASE_SCHEMAS.getBaseSchemaWithNotifications());
NetconfMessage netconfMessage = transformer.toRpcRequest(CREATE_SUBSCRIPTION_RPC_QNAME, CREATE_SUBSCRIPTION_RPC_CONTENT);
String documentString = XmlUtil.toString(netconfMessage.getDocument());
assertThat(documentString, CoreMatchers.containsString("<create-subscription"));
assertThat(documentString, CoreMatchers.containsString("<rpc"));
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfMessageTransformerTest method toActionEmptyBodyWithoutOutputDefinedResultTest.
@Test
public void toActionEmptyBodyWithoutOutputDefinedResultTest() throws Exception {
NetconfMessage message = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<ok/>" + "</rpc-reply>"));
DOMActionResult actionResult = actionNetconfMessageTransformer.toActionResult(CHECK_WITHOUT_OUTPUT_INTERFACE_PATH, message);
assertNotNull(actionResult);
assertTrue(actionResult.getOutput().isEmpty());
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class BaseRpcSchemalessTransformerTest method toRpcRequest.
@Test
public void toRpcRequest() throws Exception {
final Document doc = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/schemaless/edit-config/container.xml"));
final DOMSourceAnyxmlNode xml = Builders.anyXmlBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_CONFIG_QNAME)).withValue(new DOMSource(doc.getDocumentElement())).build();
final ChoiceNode editContent = Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(EditContent.QNAME)).withChild(xml).build();
final ChoiceNode candidate = Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ConfigTarget.QNAME)).withChild(Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(Candidate.QNAME)).withValue(Empty.value()).build()).build();
final ContainerNode target = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_TARGET_QNAME)).withChild(candidate).build();
final ContainerNode editConfig = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)).withChild(editContent).withChild(target).build();
final NetconfMessage msg = transformer.toRpcRequest(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, editConfig);
final Diff diff = XMLUnit.compareXML(EXP_RPC, XmlUtil.toString(msg.getDocument()));
assertTrue(diff.toString(), diff.similar());
}
Aggregations