Search in sources :

Example 1 with AddFlowsBatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImplTest method testAddFlowsBatch_failed.

@Test
public void testAddFlowsBatch_failed() throws Exception {
    Mockito.when(salFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError").buildFuture());
    final AddFlowsBatchInput input = new AddFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchAddFlows(Lists.newArrayList(createEmptyBatchAddFlow(FLOW_ID_VALUE_1, 42), createEmptyBatchAddFlow(FLOW_ID_VALUE_2, 43))).build();
    final Future<RpcResult<AddFlowsBatchOutput>> resultFuture = salFlowsBatchService.addFlowsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertFalse(resultFuture.get().isSuccessful());
    Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size());
    Assert.assertEquals(FLOW_ID_VALUE_1, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
    Assert.assertEquals(FLOW_ID_VALUE_2, resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
    Assert.assertEquals(2, resultFuture.get().getErrors().size());
    final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
    inOrder.verify(salFlowService, Mockito.times(2)).addFlow(addFlowInputCpt.capture());
    final List<AddFlowInput> allValues = addFlowInputCpt.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());
}
Also used : AddFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) AddFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput) Test(org.junit.Test)

Example 2 with AddFlowsBatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder in project openflowplugin by opendaylight.

the class FlatBatchFlowAdapters method adaptFlatBatchAddFlow.

/**
 * Adapt flat batch add flow.
 * @param planStep batch step containing changes of the same type
 * @param node     pointer for RPC routing
 * @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
 * .opendaylight.flows.service.rev160314.SalFlowsBatchService#addFlowsBatch(AddFlowsBatchInput)}
 */
public static AddFlowsBatchInput adaptFlatBatchAddFlow(final BatchPlanStep planStep, final NodeRef node) {
    final List<BatchAddFlows> batchFlows = new ArrayList<>();
    for (FlatBatchAddFlow batchAddFlows : planStep.<FlatBatchAddFlow>getTaskBag()) {
        final BatchAddFlows addFlows = new BatchAddFlowsBuilder((Flow) batchAddFlows).setFlowId(batchAddFlows.getFlowId()).build();
        batchFlows.add(addFlows);
    }
    return new AddFlowsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchAddFlows(batchFlows).build();
}
Also used : AddFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder) BatchAddFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlows) ArrayList(java.util.ArrayList) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) BatchAddFlowsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlowsBuilder)

Example 3 with AddFlowsBatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImplTest method testAddFlowsBatch_success.

@Test
public void testAddFlowsBatch_success() throws Exception {
    Mockito.when(salFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    final AddFlowsBatchInput input = new AddFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchAddFlows(Lists.newArrayList(createEmptyBatchAddFlow("ut-dummy-flow1", 42), createEmptyBatchAddFlow("ut-dummy-flow2", 43))).build();
    final Future<RpcResult<AddFlowsBatchOutput>> resultFuture = salFlowsBatchService.addFlowsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertTrue(resultFuture.get().isSuccessful());
    final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
    inOrder.verify(salFlowService, Mockito.times(2)).addFlow(addFlowInputCpt.capture());
    final List<AddFlowInput> allValues = addFlowInputCpt.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());
}
Also used : AddFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) AddFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) Test(org.junit.Test)

Aggregations

AddFlowsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder)3 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)2 AddFlowsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 ArrayList (java.util.ArrayList)1 FlatBatchAddFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow)1 AddFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder)1 BatchAddFlows (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlows)1 BatchAddFlowsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlowsBuilder)1