Search in sources :

Example 1 with RemoveFlowsDsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder 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();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder) AddFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput) BulkFlowDsItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder) BulkFlowDsItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem) AddFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder) RemoveFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 AddFlowsDsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput)1 AddFlowsDsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder)1 RemoveFlowsDsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput)1 RemoveFlowsDsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder)1 BulkFlowDsItem (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem)1 BulkFlowDsItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder)1 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1