use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder in project openflowplugin by opendaylight.
the class SalBulkFlowServiceImplTest method testAddRemoveFlowsDs.
@Test
public void testAddRemoveFlowsDs() throws Exception {
Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")).setTableId((short) 2);
final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
bulkFlowDsItems.add(bulkFlowDsItem);
final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
salBulkFlowService.addFlowsDs(addFlowsDsInput);
verify(writeTransaction).submit();
verify(writeTransaction).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
Flow flow = flowArgumentCaptor.getValue();
Assert.assertEquals("1", flow.getId().getValue());
Assert.assertEquals((short) 2, flow.getTableId().shortValue());
final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
verify(writeTransaction).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
verify(writeTransaction, times(2)).submit();
}
Aggregations