2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.util;
11 import com.google.common.collect.Lists;
12 import java.util.ArrayList;
13 import java.util.EnumSet;
14 import java.util.List;
15 import org.junit.Assert;
16 import org.junit.Test;
17 import org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep;
18 import org.opendaylight.openflowplugin.impl.services.batch.BatchStepType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.BatchChoice;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowKey;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupKey;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterKey;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowKey;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupKey;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterKey;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroup;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupKey;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterKey;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureKey;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
65 import org.opendaylight.yangtools.yang.common.RpcError;
66 import org.opendaylight.yangtools.yang.common.RpcResult;
67 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
68 import org.opendaylight.yangtools.yang.common.Uint16;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
73 * Test for {@link FlatBatchUtil}.
75 public class FlatBatchUtilTest {
77 private static final Logger LOG = LoggerFactory.getLogger(FlatBatchUtilTest.class);
80 public void testMarkBarriersWhereNeeded_noBarrier() {
81 final List<Batch> batches = Lists.newArrayList(
82 //general part - no flush required
83 createBatch(BatchStepType.GROUP_REMOVE),
84 createBatch(BatchStepType.METER_REMOVE),
85 createBatch(BatchStepType.FLOW_ADD),
86 createBatch(BatchStepType.FLOW_REMOVE, 2),
87 createBatch(BatchStepType.FLOW_ADD),
88 createBatch(BatchStepType.FLOW_UPDATE),
89 createBatch(BatchStepType.GROUP_ADD),
90 createBatch(BatchStepType.GROUP_UPDATE),
91 createBatch(BatchStepType.METER_ADD),
92 createBatch(BatchStepType.METER_UPDATE)
95 final List<BatchPlanStep> batchPlan = FlatBatchUtil.assembleBatchPlan(batches);
96 FlatBatchUtil.markBarriersWhereNeeded(batchPlan);
98 Assert.assertEquals(10, batchPlan.size());
99 for (int i = 0; i < batchPlan.size(); i++) {
100 final BatchPlanStep planStep = batchPlan.get(i);
101 final boolean barrierBefore = planStep.isBarrierAfter();
102 LOG.debug("checking barrier mark @ {} {} -> {}",
103 i, planStep.getStepType(), barrierBefore);
105 Assert.assertFalse(barrierBefore);
110 public void testMarkBarriersWhereNeeded_allBarriers() {
111 // need to flush G+/F+
112 checkBarriersBetween(BatchStepType.GROUP_ADD, BatchStepType.FLOW_ADD);
113 // need to flush G+/F*
114 checkBarriersBetween(BatchStepType.GROUP_ADD, BatchStepType.FLOW_UPDATE);
115 // need to flush F-/G-
116 checkBarriersBetween(BatchStepType.FLOW_REMOVE, BatchStepType.GROUP_REMOVE);
117 // need to flush F*/G-
118 checkBarriersBetween(BatchStepType.FLOW_UPDATE, BatchStepType.GROUP_REMOVE);
120 // need to flush G+/G+
121 checkBarriersBetween(BatchStepType.GROUP_ADD, BatchStepType.GROUP_ADD);
122 // need to flush G-/G-
123 checkBarriersBetween(BatchStepType.GROUP_REMOVE, BatchStepType.GROUP_REMOVE);
124 // need to flush G*/G+
125 checkBarriersBetween(BatchStepType.GROUP_UPDATE, BatchStepType.GROUP_ADD);
126 // need to flush G*/G-
127 checkBarriersBetween(BatchStepType.GROUP_UPDATE, BatchStepType.GROUP_REMOVE);
129 // need to flush M+/F+
130 checkBarriersBetween(BatchStepType.METER_ADD, BatchStepType.FLOW_ADD);
131 // need to flush M+/F*
132 checkBarriersBetween(BatchStepType.METER_ADD, BatchStepType.FLOW_UPDATE);
133 // need to flush F-/M-
134 checkBarriersBetween(BatchStepType.FLOW_REMOVE, BatchStepType.METER_REMOVE);
135 // need to flush F*/M-
136 checkBarriersBetween(BatchStepType.FLOW_UPDATE, BatchStepType.METER_REMOVE);
139 private void checkBarriersBetween(final BatchStepType typeOfFirst, final BatchStepType typeOfSecond) {
140 final List<Batch> batches = Lists.newArrayList(createBatch(typeOfFirst), createBatch(typeOfSecond));
141 final List<BatchPlanStep> batchPlan = FlatBatchUtil.assembleBatchPlan(batches);
142 FlatBatchUtil.markBarriersWhereNeeded(batchPlan);
143 LOG.debug("checking barrier between {} / {}", typeOfFirst, typeOfSecond);
144 Assert.assertEquals(2, batchPlan.size());
145 Assert.assertTrue("barrier expected between "
146 + typeOfFirst + " / "
147 + typeOfSecond, batchPlan.get(0).isBarrierAfter());
148 Assert.assertFalse(batchPlan.get(1).isBarrierAfter());
152 public void testMarkBarriersWhereNeeded_single() {
153 final List<Batch> batches = Lists.newArrayList(
154 //general part - no flush required
155 createBatch(BatchStepType.GROUP_REMOVE)
158 final List<BatchPlanStep> batchPlan = FlatBatchUtil.assembleBatchPlan(batches);
159 FlatBatchUtil.markBarriersWhereNeeded(batchPlan);
161 Assert.assertEquals(1, batchPlan.size());
162 Assert.assertFalse(batchPlan.get(0).isBarrierAfter());
166 public void testDecideBarrier() {
167 Assert.assertTrue(FlatBatchUtil.decideBarrier(EnumSet.of(BatchStepType.GROUP_ADD), BatchStepType.FLOW_ADD));
168 Assert.assertTrue(FlatBatchUtil.decideBarrier(EnumSet.of(BatchStepType.GROUP_ADD), BatchStepType.FLOW_UPDATE));
170 Assert.assertTrue(FlatBatchUtil
171 .decideBarrier(EnumSet.of(BatchStepType.FLOW_REMOVE), BatchStepType.GROUP_REMOVE));
172 Assert.assertTrue(FlatBatchUtil
173 .decideBarrier(EnumSet.of(BatchStepType.FLOW_UPDATE), BatchStepType.GROUP_REMOVE));
175 Assert.assertTrue(FlatBatchUtil.decideBarrier(EnumSet.of(BatchStepType.METER_ADD), BatchStepType.FLOW_ADD));
176 Assert.assertTrue(FlatBatchUtil.decideBarrier(EnumSet.of(BatchStepType.METER_ADD), BatchStepType.FLOW_UPDATE));
178 Assert.assertTrue(FlatBatchUtil
179 .decideBarrier(EnumSet.of(BatchStepType.FLOW_REMOVE), BatchStepType.METER_REMOVE));
180 Assert.assertTrue(FlatBatchUtil
181 .decideBarrier(EnumSet.of(BatchStepType.FLOW_UPDATE), BatchStepType.METER_REMOVE));
185 public void testAssembleBatchPlan() {
186 final List<Batch> batches = Lists.newArrayList(
187 createBatch(BatchStepType.GROUP_ADD),
188 createBatch(BatchStepType.GROUP_REMOVE, 2),
189 createBatch(BatchStepType.GROUP_REMOVE),
190 createBatch(BatchStepType.GROUP_ADD),
191 createBatch(BatchStepType.GROUP_UPDATE, 3)
194 final List<BatchPlanStep> batchPlanSteps = FlatBatchUtil.assembleBatchPlan(batches);
195 Assert.assertEquals(5, batchPlanSteps.size());
198 checkSegment(batchPlanSteps.get(index++), BatchStepType.GROUP_ADD, 1);
199 checkSegment(batchPlanSteps.get(index++), BatchStepType.GROUP_REMOVE, 2);
200 checkSegment(batchPlanSteps.get(index++), BatchStepType.GROUP_REMOVE, 1);
201 checkSegment(batchPlanSteps.get(index++), BatchStepType.GROUP_ADD, 1);
202 checkSegment(batchPlanSteps.get(index++), BatchStepType.GROUP_UPDATE, 3);
205 private void checkSegment(final BatchPlanStep planStep, final BatchStepType stepType, final int expected) {
206 Assert.assertEquals(stepType, planStep.getStepType());
207 Assert.assertEquals(expected, planStep.getTaskBag().size());
211 public void testDetectBatchStepType() {
212 for (BatchStepType stepType : BatchStepType.values()) {
213 LOG.debug("checking detection of: {}", stepType);
214 final Batch batch = createBatch(stepType);
215 final BatchStepType actualType = FlatBatchUtil.detectBatchStepType(batch.getBatchChoice());
216 Assert.assertEquals(stepType, actualType);
220 private Batch createBatch(BatchStepType type) {
221 return createBatch(type, 1);
224 private Batch createBatch(BatchStepType type, final int size) {
225 final BatchChoice batchCase;
228 batchCase = new FlatBatchAddFlowCaseBuilder()
229 .setFlatBatchAddFlow(repeatFlatBatchAddFlowIntoList(size))
233 batchCase = new FlatBatchRemoveFlowCaseBuilder()
234 .setFlatBatchRemoveFlow(repeatFlatBatchRemoveFlowIntoList(size))
238 batchCase = new FlatBatchUpdateFlowCaseBuilder()
239 .setFlatBatchUpdateFlow(repeatFlatBatchUpdateFlowIntoList(size))
243 batchCase = new FlatBatchAddGroupCaseBuilder()
244 .setFlatBatchAddGroup(repeatFlatBatchAddGroupIntoList(size))
248 batchCase = new FlatBatchRemoveGroupCaseBuilder()
249 .setFlatBatchRemoveGroup(repeatFlatBatchRemoveGroupIntoList(size))
253 batchCase = new FlatBatchUpdateGroupCaseBuilder()
254 .setFlatBatchUpdateGroup(repeatFlatBatchUpdateGroupIntoList(size))
258 batchCase = new FlatBatchAddMeterCaseBuilder()
259 .setFlatBatchAddMeter(repeatFlatBatchAddMeterIntoList(size))
263 batchCase = new FlatBatchRemoveMeterCaseBuilder()
264 .setFlatBatchRemoveMeter(repeatFlatBatchRemoveMeterIntoList(size))
268 batchCase = new FlatBatchUpdateMeterCaseBuilder()
269 .setFlatBatchUpdateMeter(repeatFlatBatchUpdateMeterIntoList(size))
273 LOG.warn("unsupported batch type: {}", type);
274 throw new IllegalArgumentException("unsupported batch type: " + type);
277 return new BatchBuilder()
278 .setBatchChoice(batchCase)
282 private List<FlatBatchAddGroup> repeatFlatBatchAddGroupIntoList(final int size) {
283 final List<FlatBatchAddGroup> list = new ArrayList<>();
284 for (int i = 0; i < size; i++) {
285 list.add(new FlatBatchAddGroupBuilder().withKey(new FlatBatchAddGroupKey(i)).build());
290 private List<FlatBatchUpdateGroup> repeatFlatBatchUpdateGroupIntoList(final int size) {
291 final List<FlatBatchUpdateGroup> list = new ArrayList<>();
292 for (int i = 0; i < size; i++) {
293 list.add(new FlatBatchUpdateGroupBuilder().withKey(new FlatBatchUpdateGroupKey(i)).build());
298 private List<FlatBatchRemoveGroup> repeatFlatBatchRemoveGroupIntoList(final int size) {
299 final List<FlatBatchRemoveGroup> list = new ArrayList<>();
300 for (int i = 0; i < size; i++) {
301 list.add(new FlatBatchRemoveGroupBuilder().withKey(new FlatBatchRemoveGroupKey(i)).build());
306 private List<FlatBatchAddFlow> repeatFlatBatchAddFlowIntoList(final int size) {
307 final List<FlatBatchAddFlow> list = new ArrayList<>();
308 for (int i = 0; i < size; i++) {
309 list.add(new FlatBatchAddFlowBuilder().withKey(new FlatBatchAddFlowKey(i)).build());
314 private List<FlatBatchUpdateFlow> repeatFlatBatchUpdateFlowIntoList(final int size) {
315 final List<FlatBatchUpdateFlow> list = new ArrayList<>();
316 for (int i = 0; i < size; i++) {
317 list.add(new FlatBatchUpdateFlowBuilder().withKey(new FlatBatchUpdateFlowKey(i)).build());
322 private List<FlatBatchRemoveFlow> repeatFlatBatchRemoveFlowIntoList(final int size) {
323 final List<FlatBatchRemoveFlow> list = new ArrayList<>();
324 for (int i = 0; i < size; i++) {
325 list.add(new FlatBatchRemoveFlowBuilder().withKey(new FlatBatchRemoveFlowKey(i)).build());
330 private List<FlatBatchAddMeter> repeatFlatBatchAddMeterIntoList(final int size) {
331 final List<FlatBatchAddMeter> list = new ArrayList<>();
332 for (int i = 0; i < size; i++) {
333 list.add(new FlatBatchAddMeterBuilder().withKey(new FlatBatchAddMeterKey(i)).build());
338 private List<FlatBatchUpdateMeter> repeatFlatBatchUpdateMeterIntoList(final int size) {
339 final List<FlatBatchUpdateMeter> list = new ArrayList<>();
340 for (int i = 0; i < size; i++) {
341 list.add(new FlatBatchUpdateMeterBuilder().withKey(new FlatBatchUpdateMeterKey(i)).build());
346 private List<FlatBatchRemoveMeter> repeatFlatBatchRemoveMeterIntoList(final int size) {
347 final List<FlatBatchRemoveMeter> list = new ArrayList<>();
348 for (int i = 0; i < size; i++) {
349 list.add(new FlatBatchRemoveMeterBuilder().withKey(new FlatBatchRemoveMeterKey(i)).build());
355 public void testMergeJobsResultsFutures() {
356 final BatchFailure batchFailure = new BatchFailureBuilder()
358 .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
359 .setFlowId(new FlowId("11"))
361 .withKey(new BatchFailureKey(Uint16.ZERO))
363 final BatchFailure batchFailure_1 = new BatchFailureBuilder()
365 .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
366 .setFlowId(new FlowId("11"))
368 .withKey(new BatchFailureKey(Uint16.ONE))
371 final ProcessFlatBatchOutput output
372 = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
374 final ProcessFlatBatchOutput output_1
375 = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure_1)).build();
377 final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed()
378 .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError")
379 .withResult(output).build();
381 final RpcResult<ProcessFlatBatchOutput> rpcResultFailed_1 = RpcResultBuilder.<ProcessFlatBatchOutput>failed()
382 .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError")
383 .withResult(output_1).build();
384 final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success()
385 .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
387 final RpcResult<ProcessFlatBatchOutput> rpcResult1
388 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess));
389 Assert.assertEquals(1, rpcResult1.getErrors().size());
390 Assert.assertFalse(rpcResult1.isSuccessful());
392 final RpcResult<ProcessFlatBatchOutput> rpcResult2
393 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed_1));
394 Assert.assertEquals(2, rpcResult2.getErrors().size());
395 Assert.assertFalse(rpcResult2.isSuccessful());
397 final RpcResult<ProcessFlatBatchOutput> rpcResult3
398 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultSuccess, rpcResultSuccess));
399 Assert.assertEquals(0, rpcResult3.getErrors().size());
400 Assert.assertTrue(rpcResult3.isSuccessful());