import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Matchers;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- *
+ * Test for
+ * {@link org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.FlowNotificationSupplierImpl}.
*/
public class FlowNotificationSupplierImplTest {
notifProviderService = mock(NotificationProviderService.class);
dataBroker = mock(DataBroker.class);
notifSupplierImpl = new FlowNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataChangeRegistration(dataBroker);
+ TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
}
@Test(expected = NullPointerException.class)
public void testCreate() {
final FlowAdded notification = notifSupplierImpl.createNotification(createTestFlow(), createTestFlowPath());
assertNotNull(notification);
- assertEquals(FLOW_ID, notification.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID, notification.getFlowRef().getValue().firstKeyOf(Table.class, TableKey.class).getId());
- assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+ assertEquals(FLOW_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
+ assertEquals(FLOW_TABLE_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
+ assertEquals(FLOW_NODE_ID,
+ notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
}
@Test
public void testCreateChangeEvent() {
- final TestData testData = new TestData(createTestFlowPath(),null,createTestFlow(),
- DataObjectModification.ModificationType.WRITE);
+ final TestData testData = new TestData(createTestFlowPath(), null, createTestFlow(),
+ DataObjectModification.ModificationType.WRITE);
Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).publish(Matchers.any(FlowAdded.class));
+ verify(notifProviderService, times(1)).publish(any(FlowAdded.class));
}
@Test(expected = IllegalArgumentException.class)
public void testUpdate() {
final FlowUpdated notification = notifSupplierImpl.updateNotification(createTestFlow(), createTestFlowPath());
assertNotNull(notification);
- assertEquals(FLOW_ID, notification.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID, notification.getFlowRef().getValue().firstKeyOf(Table.class, TableKey.class).getId());
- assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+ assertEquals(FLOW_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
+ assertEquals(FLOW_TABLE_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
+ assertEquals(FLOW_NODE_ID,
+ notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
}
@Test
public void testUpdateChangeEvent() {
- final TestData testData = new TestData(createTestFlowPath(),createTestFlow(),createUpdatedTestFlow(),
- DataObjectModification.ModificationType.SUBTREE_MODIFIED);
+ final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), createUpdatedTestFlow(),
+ DataObjectModification.ModificationType.SUBTREE_MODIFIED);
Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).publish(Matchers.any(FlowUpdated.class));
+ verify(notifProviderService, times(1)).publish(any(FlowUpdated.class));
}
@Test(expected = IllegalArgumentException.class)
public void testDelete() {
final FlowRemoved notification = notifSupplierImpl.deleteNotification(createTestFlowPath());
assertNotNull(notification);
- assertEquals(FLOW_ID, notification.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID, notification.getFlowRef().getValue().firstKeyOf(Table.class, TableKey.class).getId());
- assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+ assertEquals(FLOW_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
+ assertEquals(FLOW_TABLE_ID,
+ notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
+ assertEquals(FLOW_NODE_ID,
+ notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
}
@Test
public void testDeleteChangeEvent() {
- final TestData testData = new TestData(createTestFlowPath(),createTestFlow(),null,
- DataObjectModification.ModificationType.DELETE);
+ final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), null,
+ DataObjectModification.ModificationType.DELETE);
Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).publish(Matchers.any(FlowRemoved.class));
+ verify(notifProviderService, times(1)).publish(any(FlowRemoved.class));
}
@Test(expected = IllegalArgumentException.class)
return builder.build();
}
- private static Flow createUpdatedTestFlow(){
+ private static Flow createUpdatedTestFlow() {
final FlowBuilder builder = new FlowBuilder();
builder.setId(new FlowId(UPDATED_FLOW_ID));
builder.setTableId(UPDATED_FLOW_TABLE_ID);