use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping in project openflowplugin by opendaylight.
the class FlatBatchFlowAdaptersTest method testCreateBatchFlowChainingFunction_successes.
@Test
public void testCreateBatchFlowChainingFunction_successes() throws Exception {
final RpcResult<BatchFlowOutputListGrouping> input = RpcResultBuilder.<BatchFlowOutputListGrouping>success(new AddFlowsBatchOutputBuilder().build()).build();
final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchFlowAdapters.convertBatchFlowResult(0).apply(input);
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping 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.flows.service.rev160314.BatchFlowOutputListGrouping in project openflowplugin by opendaylight.
the class FlatBatchFlowAdapters method wrapBatchFlowFailuresForFlat.
private static <T extends BatchFlowOutputListGrouping> List<BatchFailure> wrapBatchFlowFailuresForFlat(final RpcResult<T> input, final int stepOffset) {
final List<BatchFailure> batchFailures = new ArrayList<>();
if (input.getResult().getBatchFailedFlowsOutput() != null) {
for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) {
final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(stepOffset + stepOutput.getBatchOrder()).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(stepOutput.getFlowId()).build()).build();
batchFailures.add(batchFailure);
}
}
return batchFailures;
}
Aggregations