Search in sources :

Example 1 with BatchMeterOutputListGrouping

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());
}
Also used : BatchMeterOutputListGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping) AddMetersBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.AddMetersBatchOutputBuilder) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) Test(org.junit.Test)

Example 2 with BatchMeterOutputListGrouping

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;
}
Also used : BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) BatchFailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder) ArrayList(java.util.ArrayList) BatchFailedMetersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput) FlatBatchFailureMeterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureMeterIdCaseBuilder)

Example 3 with BatchMeterOutputListGrouping

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();
        }
    };
}
Also used : Function(com.google.common.base.Function) BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) ProcessFlatBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder) Nonnull(javax.annotation.Nonnull) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ProcessFlatBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput)2 BatchFailure (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Function (com.google.common.base.Function)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 Test (org.junit.Test)1 ProcessFlatBatchOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder)1 BatchFailureBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder)1 FlatBatchFailureMeterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureMeterIdCaseBuilder)1 AddMetersBatchOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.AddMetersBatchOutputBuilder)1 BatchMeterOutputListGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping)1 BatchFailedMetersOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1