use of org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep in project openflowplugin by opendaylight.
the class SalFlatBatchServiceImplTest method testPrepareBatchPlan_success.
@Test
public void testPrepareBatchPlan_success() throws Exception {
final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder().setFlowId(new FlowId("f1")).build();
final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD);
batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow));
final List<BatchPlanStep> batchPlan = Lists.newArrayList(batchPlanStep);
final List<BatchStepJob> batchChain = salFlatBatchService.prepareBatchChain(batchPlan, NODE_REF, true);
Assert.assertEquals(1, batchChain.size());
Mockito.when(salFlowsBatchService.addFlowsBatch(Matchers.<AddFlowsBatchInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowsBatchOutputBuilder().build()).buildFuture());
final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture = salFlatBatchService.executeBatchPlan(batchChain);
Assert.assertTrue(rpcResultFuture.isDone());
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
Mockito.verify(salFlowsBatchService).addFlowsBatch(Matchers.<AddFlowsBatchInput>any());
}
use of org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep in project openflowplugin by opendaylight.
the class FlatBatchUtil method assembleBatchPlan.
public static List<BatchPlanStep> assembleBatchPlan(List<Batch> batches) {
final List<BatchPlanStep> plan = new ArrayList<>();
BatchPlanStep planStep;
for (Batch batch : batches) {
final BatchStepType nextStepType = detectBatchStepType(batch.getBatchChoice());
planStep = new BatchPlanStep(nextStepType);
planStep.getTaskBag().addAll(extractBatchData(planStep.getStepType(), batch.getBatchChoice()));
if (!planStep.isEmpty()) {
plan.add(planStep);
}
}
return plan;
}
Aggregations