Search in sources :

Example 1 with BatchGroupOutputListGrouping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping 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();
        }
    };
}
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)

Example 2 with BatchGroupOutputListGrouping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping in project openflowplugin by opendaylight.

the class FlatBatchGroupAdapters method wrapBatchGroupFailuresForFlat.

private static <T extends BatchGroupOutputListGrouping> List<BatchFailure> wrapBatchGroupFailuresForFlat(final RpcResult<T> input, final int stepOffset) {
    final List<BatchFailure> batchFailures = new ArrayList<>();
    if (input.getResult().getBatchFailedGroupsOutput() != null) {
        for (BatchFailedGroupsOutput stepOutput : input.getResult().getBatchFailedGroupsOutput()) {
            final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(stepOffset + stepOutput.getBatchOrder()).setBatchItemIdChoice(new FlatBatchFailureGroupIdCaseBuilder().setGroupId(stepOutput.getGroupId()).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) BatchFailedGroupsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput) ArrayList(java.util.ArrayList) FlatBatchFailureGroupIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureGroupIdCaseBuilder)

Example 3 with BatchGroupOutputListGrouping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping in project openflowplugin by opendaylight.

the class FlatBatchGroupAdaptersTest method testCreateBatchGroupChainingFunction_successes.

@Test
public void testCreateBatchGroupChainingFunction_successes() throws Exception {
    final RpcResult<BatchGroupOutputListGrouping> input = RpcResultBuilder.<BatchGroupOutputListGrouping>success(new AddGroupsBatchOutputBuilder().build()).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchGroupAdapters.convertBatchGroupResult(0).apply(input);
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(0, rpcResult.getErrors().size());
    Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
}
Also used : BatchGroupOutputListGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping) AddGroupsBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchOutputBuilder) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) Test(org.junit.Test)

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 FlatBatchFailureGroupIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureGroupIdCaseBuilder)1 AddGroupsBatchOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchOutputBuilder)1 BatchGroupOutputListGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping)1 BatchFailedGroupsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1