Search in sources :

Example 11 with EmptyMountPointContext

use of org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext in project netconf by opendaylight.

the class NetconfNestedNotificationTest method testNestedNotificationToNotificationFunction.

@Test
public void testNestedNotificationToNotificationFunction() throws Exception {
    final EffectiveModelContext schemaContext = getNotificationSchemaContext(Collections.singleton("/schemas/nested-notification.yang"));
    final NetconfMessage notificationMessage = prepareNotification("/nested-notification-payload.xml");
    NetconfMessageTransformer messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true, BASE_SCHEMAS.getBaseSchema());
    final DOMNotification domNotification = messageTransformer.toNotification(notificationMessage);
    final ContainerNode root = domNotification.getBody();
    assertNotNull(root);
    assertEquals(1, root.body().size());
    assertEquals("interface-enabled", root.getIdentifier().getNodeType().getLocalName());
    assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2008-07-08T00:01:00Z").toInstant(), ((DOMEvent) domNotification).getEventInstant());
    assertEquals(Absolute.of(INTERFACES_QNAME, INTERFACE_QNAME, INTERFACE_ENABLED_NOTIFICATION_QNAME), domNotification.getType());
}
Also used : EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 12 with EmptyMountPointContext

use of org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext in project netconf by opendaylight.

the class NetconfToNotificationTest method testToNotificationFunction.

@Test
public void testToNotificationFunction() throws Exception {
    final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), false);
    messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true, BASE_SCHEMAS.getBaseSchema());
    final DOMNotification domNotification = messageTransformer.toNotification(userNotification);
    final ContainerNode root = domNotification.getBody();
    assertNotNull(root);
    assertEquals(6, root.body().size());
    assertEquals("user-visited-page", root.getIdentifier().getNodeType().getLocalName());
    assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2015-10-23T09:42:27.67175+00:00").toInstant(), ((DOMEvent) domNotification).getEventInstant());
}
Also used : EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 13 with EmptyMountPointContext

use of org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext in project netconf by opendaylight.

the class NetconfDeviceRpcTest method setUp.

@Before
public void setUp() throws Exception {
    NetconfMessageTransformer transformer = new NetconfMessageTransformer(new EmptyMountPointContext(SCHEMA_CONTEXT), true, BASE_SCHEMAS.getBaseSchema());
    final NetconfMessage reply = new NetconfMessage(XmlUtil.readXmlToDocument("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" + "<data>\n" + "</data>\n" + "</rpc-reply>"));
    RpcResult<NetconfMessage> result = RpcResultBuilder.success(reply).build();
    doReturn(Futures.immediateFuture(result)).when(communicator).sendRequest(any(NetconfMessage.class), any(QName.class));
    rpc = new NetconfDeviceRpc(SCHEMA_CONTEXT, communicator, transformer);
    type = QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "get-config");
    expectedReply = transformer.toRpcResult(reply, type);
}
Also used : EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) QName(org.opendaylight.yangtools.yang.common.QName) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) Before(org.junit.Before)

Example 14 with EmptyMountPointContext

use of org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext in project netconf by opendaylight.

the class NetconfDeviceSalFacadeTest method testOnDeviceConnected.

@Test
public void testOnDeviceConnected() {
    final EffectiveModelContext schemaContext = mock(EffectiveModelContext.class);
    final NetconfSessionPreferences netconfSessionPreferences = NetconfSessionPreferences.fromStrings(getCapabilities());
    final DOMRpcService deviceRpc = mock(DOMRpcService.class);
    deviceFacade.onDeviceConnected(new EmptyMountPointContext(schemaContext), netconfSessionPreferences, deviceRpc, null);
    verify(mountInstance, times(1)).onTopologyDeviceConnected(eq(schemaContext), any(DOMDataBroker.class), any(NetconfDataTreeService.class), eq(deviceRpc), any(NetconfDeviceNotificationService.class), isNull());
    verify(netconfDeviceTopologyAdapter, times(1)).updateDeviceData(true, netconfSessionPreferences.getNetconfDeviceCapabilities());
}
Also used : DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 15 with EmptyMountPointContext

use of org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method setUp.

@Before
public void setUp() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpcService).invokeRpc(any(), any());
    netconService = getNetconService();
    final EffectiveModelContext model = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class, NetconfState.class);
    netconfMessageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(model), true, BASE_SCHEMAS.getBaseSchema());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Before(org.junit.Before)

Aggregations

EmptyMountPointContext (org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext)17 NetconfMessageTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer)7 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)7 Before (org.junit.Before)6 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)6 Test (org.junit.Test)5 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)4 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)3 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)3 DOMNotification (org.opendaylight.mdsal.dom.api.DOMNotification)2 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)2 NetconfDeviceRpc (org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc)2 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)2 QName (org.opendaylight.yangtools.yang.common.QName)2 Beta (com.google.common.annotations.Beta)1 ToStringHelper (com.google.common.base.MoreObjects.ToStringHelper)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableSet (com.google.common.collect.ImmutableSet)1