Search in sources :

Example 1 with NotificationPattern

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern in project controller by opendaylight.

the class EventSourceTopologyTest method closeTest.

@Test
public void closeTest() throws Exception {
    constructorTestHelper();
    topicTestHelper();
    Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
    TopicId topicIdMock = mock(TopicId.class);
    EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
    localMap.put(topicIdMock, eventSourceTopic);
    eventSourceTopology.close();
    verify(aggregatorRpcReg, times(1)).close();
    verify(listenerRegistrationMock, times(1)).close();
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) TopicId(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId) Test(org.junit.Test)

Example 2 with NotificationPattern

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern in project controller by opendaylight.

the class EventSourceTopologyTest method destroyTopicTest.

@Test
public void destroyTopicTest() throws Exception {
    topicTestHelper();
    TopicId topicId = new TopicId("topic-id-007");
    Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
    EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
    localMap.put(topicId, eventSourceTopic);
    DestroyTopicInput input = new DestroyTopicInputBuilder().setTopicId(topicId).build();
    eventSourceTopology.destroyTopic(input);
    verify(listenerRegistrationMock, times(1)).close();
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) DestroyTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput) TopicId(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId) DestroyTopicInputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInputBuilder) Test(org.junit.Test)

Example 3 with NotificationPattern

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern in project controller by opendaylight.

the class EventSourceTopic method getJoinTopicInputArgument.

private JoinTopicInput getJoinTopicInputArgument(final InstanceIdentifier<?> path) {
    final NodeRef nodeRef = new NodeRef(path);
    final JoinTopicInput jti = new JoinTopicInputBuilder().setNode(nodeRef.getValue()).setTopicId(topicId).setNotificationPattern(notificationPattern).build();
    return jti;
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) DisJoinTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput) JoinTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput) DisJoinTopicInputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInputBuilder) JoinTopicInputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInputBuilder)

Example 4 with NotificationPattern

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern in project controller by opendaylight.

the class EventSourceTopology method createTopic.

@Override
public Future<RpcResult<CreateTopicOutput>> createTopic(final CreateTopicInput input) {
    LOG.debug("Received Topic creation request: NotificationPattern -> {}, NodeIdPattern -> {}", input.getNotificationPattern(), input.getNodeIdPattern());
    final NotificationPattern notificationPattern = new NotificationPattern(input.getNotificationPattern());
    // FIXME: do not use Util.wildcardToRegex - NodeIdPatter should be regex
    final String nodeIdPattern = input.getNodeIdPattern().getValue();
    final EventSourceTopic eventSourceTopic = EventSourceTopic.create(notificationPattern, nodeIdPattern, this);
    eventSourceTopicMap.put(eventSourceTopic.getTopicId(), eventSourceTopic);
    final CreateTopicOutput cto = new CreateTopicOutputBuilder().setTopicId(eventSourceTopic.getTopicId()).build();
    LOG.info("Topic has been created: NotificationPattern -> {}, NodeIdPattern -> {}", input.getNotificationPattern(), input.getNodeIdPattern());
    return Util.resultRpcSuccessFor(cto);
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) CreateTopicOutput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutput) CreateTopicOutputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutputBuilder)

Example 5 with NotificationPattern

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern in project controller by opendaylight.

the class EventSourceTopicTest method setUp.

@Before
public void setUp() throws Exception {
    final NotificationPattern notificationPattern = new NotificationPattern("value1");
    eventSourceServiceMock = mock(EventSourceService.class);
    doReturn(RpcResultBuilder.success(new JoinTopicOutputBuilder().setStatus(JoinTopicStatus.Up).build()).buildFuture()).when(eventSourceServiceMock).joinTopic(any(JoinTopicInput.class));
    eventSourceTopologyMock = mock(EventSourceTopology.class);
    dataBrokerMock = mock(DataBroker.class);
    doReturn(eventSourceServiceMock).when(eventSourceTopologyMock).getEventSourceService();
    doReturn(dataBrokerMock).when(eventSourceTopologyMock).getDataBroker();
    WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
    doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
    doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
    CheckedFuture checkedFutureWriteMock = mock(CheckedFuture.class);
    doReturn(checkedFutureWriteMock).when(writeTransactionMock).submit();
    ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
    doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
    CheckedFuture checkedFutureReadMock = mock(CheckedFuture.class);
    doReturn(checkedFutureReadMock).when(readOnlyTransactionMock).read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
    eventSourceTopic = EventSourceTopic.create(notificationPattern, "nodeIdPattern1", eventSourceTopologyMock);
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) JoinTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) JoinTopicOutputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicOutputBuilder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Before(org.junit.Before)

Aggregations

NotificationPattern (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern)5 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)2 Test (org.junit.Test)2 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)2 TopicId (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId)2 JoinTopicInput (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 Optional (com.google.common.base.Optional)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 CreateTopicInput (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput)1 CreateTopicOutput (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutput)1 CreateTopicOutputBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutputBuilder)1 DestroyTopicInput (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput)1 DestroyTopicInputBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInputBuilder)1 Pattern (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern)1