use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyFlatBatchImplTest method testExecuteSyncStrategy.
@Test
public void testExecuteSyncStrategy() throws Exception {
final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
Mockito.when(flatBatchService.processFlatBatch(Matchers.<ProcessFlatBatchInput>any())).thenReturn(RpcResultBuilder.success(new ProcessFlatBatchOutputBuilder().build()).buildFuture());
final SyncCrudCounters counters = new SyncCrudCounters();
final ListenableFuture<RpcResult<Void>> rpcResult = syncPlanPushStrategy.executeSyncStrategy(RpcResultBuilder.<Void>success().buildFuture(), diffInput, counters);
Mockito.verify(flatBatchService).processFlatBatch(processFlatBatchInputCpt.capture());
final ProcessFlatBatchInput processFlatBatchInput = processFlatBatchInputCpt.getValue();
Assert.assertFalse(processFlatBatchInput.isExitOnFirstError());
Assert.assertEquals(13, processFlatBatchInput.getBatch().size());
Assert.assertTrue(rpcResult.isDone());
Assert.assertTrue(rpcResult.get().isSuccessful());
Assert.assertEquals(6, counters.getFlowCrudCounts().getAdded());
Assert.assertEquals(3, counters.getFlowCrudCounts().getUpdated());
Assert.assertEquals(6, counters.getFlowCrudCounts().getRemoved());
Assert.assertEquals(6, counters.getGroupCrudCounts().getAdded());
Assert.assertEquals(3, counters.getGroupCrudCounts().getUpdated());
Assert.assertEquals(6, counters.getGroupCrudCounts().getRemoved());
Assert.assertEquals(3, counters.getMeterCrudCounts().getAdded());
Assert.assertEquals(3, counters.getMeterCrudCounts().getUpdated());
Assert.assertEquals(3, counters.getMeterCrudCounts().getRemoved());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder in project openflowplugin by opendaylight.
the class FlatBatchFlowAdapters method convertBatchFlowResult.
/**
* Convert batch result.
* @param stepOffset offset of current batch plan step
* @return converted {@link ProcessFlatBatchOutput} RPC result
*/
@VisibleForTesting
static <T extends BatchFlowOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchFlowResult(final int stepOffset) {
return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
@Nullable
@Override
public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
List<BatchFailure> batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset);
ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder in project openflowplugin by opendaylight.
the class FlatBatchGroupAdapters method convertBatchGroupResult.
/**
* Convert batch group result.
* @param stepOffset offset of current batch plan step
* @return converted {@link ProcessFlatBatchOutput} RPC result
*/
@VisibleForTesting
static <T extends BatchGroupOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchGroupResult(final int stepOffset) {
return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
@Nullable
@Override
public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
List<BatchFailure> batchFailures = wrapBatchGroupFailuresForFlat(input, stepOffset);
ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder in project openflowplugin by opendaylight.
the class FlatBatchUtilTest method testMergeJobsResultsFutures.
@Test
public void testMergeJobsResultsFutures() throws Exception {
final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(9).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(new FlowId("11")).build()).build();
final ProcessFlatBatchOutput output = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-rpcError").withResult(output).build();
final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success().withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
final RpcResult<ProcessFlatBatchOutput> rpcResult1 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess));
Assert.assertEquals(1, rpcResult1.getErrors().size());
Assert.assertFalse(rpcResult1.isSuccessful());
final RpcResult<ProcessFlatBatchOutput> rpcResult2 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed));
Assert.assertEquals(2, rpcResult2.getErrors().size());
Assert.assertFalse(rpcResult2.isSuccessful());
final RpcResult<ProcessFlatBatchOutput> rpcResult3 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultSuccess, rpcResultSuccess));
Assert.assertEquals(0, rpcResult3.getErrors().size());
Assert.assertTrue(rpcResult3.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method convertBatchMeterResult.
/**
* Convert meter batch result.
* @param stepOffset offset of current batch plan step
* @return converted {@link ProcessFlatBatchOutput} RPC result
*/
@VisibleForTesting
static <T extends BatchMeterOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchMeterResult(final int stepOffset) {
return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
@Nullable
@Override
public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
List<BatchFailure> batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset);
ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
}
};
}
Aggregations