use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.
the class FlowForwarderTest method removeTest.
@Test
public void removeTest() throws Exception {
Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
final Flow removeFlow = new FlowBuilder(flow).build();
final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
Assert.assertEquals(2, flowInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowInput.getMatch());
Assert.assertEquals(null, flowInput.getInstructions());
Assert.assertEquals(true, flowInput.isStrict());
final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.
the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.
@Test
public void testAddRemoveFlowsRpc() throws Exception {
Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
bulkFlowItems.add(bulkFlowItem);
final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantFlows.
@Test
public void testRemoveRedundantFlows() throws Exception {
Mockito.when(flowCommitter.remove(Matchers.<InstanceIdentifier<Flow>>any(), flowCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f3", 3));
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f4", 4));
final Map<TableKey, ItemSyncBox<Flow>> flowBoxMap = new LinkedHashMap<>();
flowBoxMap.put(new TableKey((short) 0), flowBox);
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.removeRedundantFlows(NODE_ID, NODE_IDENT, flowBoxMap, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Flow> flowCaptorAllValues = flowCaptor.getAllValues();
Assert.assertEquals(2, flowCaptorAllValues.size());
Assert.assertEquals("f3", flowCaptorAllValues.get(0).getId().getValue());
Assert.assertEquals("f4", flowCaptorAllValues.get(1).getId().getValue());
final InOrder inOrderFlow = Mockito.inOrder(flowCapableTxService, flowCommitter);
inOrderFlow.verify(flowCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
inOrderFlow.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderFlow.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.
the class SalFlowsBatchServiceImplTest method testRemoveFlowsBatch_success.
@Test
public void testRemoveFlowsBatch_success() throws Exception {
Mockito.when(salFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
final String flow1IdValue = "ut-dummy-flow1";
final String flow2IdValue = "ut-dummy-flow2";
final BatchRemoveFlows batchFlow1 = createEmptyBatchRemoveFlow(flow1IdValue, 42);
final BatchRemoveFlows batchFlow2 = createEmptyBatchRemoveFlow(flow2IdValue, 43);
final RemoveFlowsBatchInput input = new RemoveFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveFlows(Lists.newArrayList(batchFlow1, batchFlow2)).build();
final Future<RpcResult<RemoveFlowsBatchOutput>> resultFuture = salFlowsBatchService.removeFlowsBatch(input);
Assert.assertTrue(resultFuture.isDone());
final RpcResult<RemoveFlowsBatchOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
final RemoveFlowsBatchOutput result = rpcResult.getResult();
Assert.assertEquals(0, result.getBatchFailedFlowsOutput().size());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
inOrder.verify(salFlowService, Mockito.times(2)).removeFlow(removeFlowInputCpt.capture());
final List<RemoveFlowInput> allValues = removeFlowInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Aggregations