Search in sources :

Example 1 with UpdateFlowsBatchInputBuilder

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

the class SalFlowsBatchServiceImplTest method testUpdateFlowsBatch_success.

@Test
public void testUpdateFlowsBatch_success() throws Exception {
    Mockito.when(salFlowService.updateFlow(Matchers.<UpdateFlowInput>any())).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
    final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateFlows(Lists.newArrayList(createEmptyBatchUpdateFlow(FLOW_ID_VALUE_1, 42), createEmptyBatchUpdateFlow(FLOW_ID_VALUE_2, 44))).build();
    final Future<RpcResult<UpdateFlowsBatchOutput>> resultFuture = salFlowsBatchService.updateFlowsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertTrue(resultFuture.get().isSuccessful());
    final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
    inOrder.verify(salFlowService, Mockito.times(2)).updateFlow(updateFlowInputCpt.capture());
    final List<UpdateFlowInput> allValues = updateFlowInputCpt.getAllValues();
    Assert.assertEquals(2, allValues.size());
    Assert.assertEquals(42, allValues.get(0).getOriginalFlow().getPriority().longValue());
    Assert.assertEquals(43, allValues.get(0).getUpdatedFlow().getPriority().longValue());
    Assert.assertEquals(44, allValues.get(1).getOriginalFlow().getPriority().longValue());
    Assert.assertEquals(45, allValues.get(1).getUpdatedFlow().getPriority().longValue());
    inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : UpdateFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder) UpdateFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput) UpdateFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput) Test(org.junit.Test)

Example 2 with UpdateFlowsBatchInputBuilder

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

the class FlatBatchFlowAdapters method adaptFlatBatchUpdateFlow.

/**
 * Adapt flat batch update 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#updateFlowsBatch(UpdateFlowsBatchInput)}
 */
public static UpdateFlowsBatchInput adaptFlatBatchUpdateFlow(final BatchPlanStep planStep, final NodeRef node) {
    final List<BatchUpdateFlows> batchFlows = new ArrayList<>();
    for (FlatBatchUpdateFlow batchUpdateFlow : planStep.<FlatBatchUpdateFlow>getTaskBag()) {
        final BatchUpdateFlows updateFlows = new BatchUpdateFlowsBuilder(batchUpdateFlow).build();
        batchFlows.add(updateFlows);
    }
    return new UpdateFlowsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchUpdateFlows(batchFlows).build();
}
Also used : UpdateFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder) BatchUpdateFlowsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlowsBuilder) ArrayList(java.util.ArrayList) FlatBatchUpdateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow) BatchUpdateFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows)

Example 3 with UpdateFlowsBatchInputBuilder

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

the class SalFlowsBatchServiceImplTest method testUpdateFlowsBatch_failure.

@Test
public void testUpdateFlowsBatch_failure() throws Exception {
    Mockito.when(salFlowService.updateFlow(Matchers.<UpdateFlowInput>any())).thenReturn(RpcResultBuilder.<UpdateFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-flowUpdateError").buildFuture());
    final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateFlows(Lists.newArrayList(createEmptyBatchUpdateFlow(FLOW_ID_VALUE_1, 42), createEmptyBatchUpdateFlow(FLOW_ID_VALUE_2, 44))).build();
    final Future<RpcResult<UpdateFlowsBatchOutput>> resultFuture = salFlowsBatchService.updateFlowsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertFalse(resultFuture.get().isSuccessful());
    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)).updateFlow(updateFlowInputCpt.capture());
    final List<UpdateFlowInput> allValues = updateFlowInputCpt.getAllValues();
    Assert.assertEquals(2, allValues.size());
    Assert.assertEquals(42, allValues.get(0).getOriginalFlow().getPriority().longValue());
    Assert.assertEquals(43, allValues.get(0).getUpdatedFlow().getPriority().longValue());
    Assert.assertEquals(44, allValues.get(1).getOriginalFlow().getPriority().longValue());
    Assert.assertEquals(45, allValues.get(1).getUpdatedFlow().getPriority().longValue());
    inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : UpdateFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput) UpdateFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput) Test(org.junit.Test)

Aggregations

UpdateFlowsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder)3 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)2 UpdateFlowsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 ArrayList (java.util.ArrayList)1 FlatBatchUpdateFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow)1 UpdateFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder)1 BatchUpdateFlows (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows)1 BatchUpdateFlowsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlowsBuilder)1