Search in sources :

Example 6 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class MeterNotificationSupplierImplTest method testDeleteChangeEvent.

@Test
public void testDeleteChangeEvent() {
    final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), null, DataObjectModification.ModificationType.DELETE);
    Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(MeterRemoved.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) MeterRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class FlowStatNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestFlowStatPath(), null, createTestFlowStat(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<FlowStatistics>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(FlowsStatisticsUpdate.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowsStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class MeterStatNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestMeterStatPath(), null, createTestMeterStat(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<MeterStatistics>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(MeterStatisticsUpdated.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) MeterStatisticsUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method setupDataTreeChange.

private <T extends DataObject> DataTreeModification setupDataTreeChange(final ModificationType type, final InstanceIdentifier<T> ii, final FlowCapableNodeConnector connector) {
    final DataTreeModification dataTreeModification = mock(DataTreeModification.class);
    when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class));
    DataTreeIdentifier<T> identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, ii);
    when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type);
    when(dataTreeModification.getRootPath()).thenReturn(identifier);
    when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(connector);
    return dataTreeModification;
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification)

Example 10 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorUpdateToLinkDown.

/**
 * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
 * for each FlowCapableNodeConnector item that have link down state removed in
 * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
 */
@Test
public void testNodeConnectorUpdateToLinkDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED, NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verify(eventsObserver).nodeConnectorRemoved(ID);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Aggregations

DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)42 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)20 TestData (org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData)19 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 Optional (com.google.common.base.Optional)4 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)4 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4