use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping in project openflowplugin by opendaylight.
the class FlatBatchMeterAdaptersTest method testCreateBatchMeterChainingFunction_successes.
@Test
public void testCreateBatchMeterChainingFunction_successes() throws Exception {
final RpcResult<BatchMeterOutputListGrouping> input = RpcResultBuilder.<BatchMeterOutputListGrouping>success(new AddMetersBatchOutputBuilder().build()).build();
final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchMeterAdapters.convertBatchMeterResult(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.meters.service.rev160316.BatchMeterOutputListGrouping in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method wrapBatchMeterFailuresForFlat.
private static <T extends BatchMeterOutputListGrouping> List<BatchFailure> wrapBatchMeterFailuresForFlat(final RpcResult<T> input, final int stepOffset) {
final List<BatchFailure> batchFailures = new ArrayList<>();
if (input.getResult().getBatchFailedMetersOutput() != null) {
for (BatchFailedMetersOutput stepOutput : input.getResult().getBatchFailedMetersOutput()) {
final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(stepOffset + stepOutput.getBatchOrder()).setBatchItemIdChoice(new FlatBatchFailureMeterIdCaseBuilder().setMeterId(stepOutput.getMeterId()).build()).build();
batchFailures.add(batchFailure);
}
}
return batchFailures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping 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