use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder in project openflowplugin by opendaylight.
the class FlatBatchGroupAdapters method adaptFlatBatchUpdateGroup.
/**
* Adapt flat batch update group.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.groups.service.rev160315.SalGroupsBatchService#updateGroupsBatch(UpdateGroupsBatchInput)}
*/
public static UpdateGroupsBatchInput adaptFlatBatchUpdateGroup(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchUpdateGroups> batchGroups = new ArrayList<>();
for (FlatBatchUpdateGroup batchUpdateGroup : planStep.<FlatBatchUpdateGroup>getTaskBag()) {
final BatchUpdateGroups updateGroups = new BatchUpdateGroupsBuilder(batchUpdateGroup).build();
batchGroups.add(updateGroups);
}
return new UpdateGroupsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchUpdateGroups(batchGroups).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImplTest method testUpdateGroupsBatch_success.
@Test
public void testUpdateGroupsBatch_success() throws Exception {
Mockito.when(salGroupService.updateGroup(Mockito.<UpdateGroupInput>any())).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().build()).buildFuture());
final UpdateGroupsBatchInput input = new UpdateGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateGroups(Lists.newArrayList(createEmptyBatchUpdateGroup(42L), createEmptyBatchUpdateGroup(44L))).build();
final Future<RpcResult<UpdateGroupsBatchOutput>> resultFuture = salGroupsBatchService.updateGroupsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertTrue(resultFuture.get().isSuccessful());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
inOrder.verify(salGroupService, Mockito.times(2)).updateGroup(updateGroupInputCpt.capture());
final List<UpdateGroupInput> allValues = updateGroupInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42, allValues.get(0).getOriginalGroup().getGroupId().getValue().longValue());
Assert.assertEquals(43, allValues.get(0).getUpdatedGroup().getGroupId().getValue().longValue());
Assert.assertEquals(44, allValues.get(1).getOriginalGroup().getGroupId().getValue().longValue());
Assert.assertEquals(45, allValues.get(1).getUpdatedGroup().getGroupId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImplTest method testUpdateGroupsBatch_failure.
@Test
public void testUpdateGroupsBatch_failure() throws Exception {
Mockito.when(salGroupService.updateGroup(Mockito.<UpdateGroupInput>any())).thenReturn(RpcResultBuilder.<UpdateGroupOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ur-groupUpdateError").buildFuture());
final UpdateGroupsBatchInput input = new UpdateGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateGroups(Lists.newArrayList(createEmptyBatchUpdateGroup(42L), createEmptyBatchUpdateGroup(44L))).build();
final Future<RpcResult<UpdateGroupsBatchOutput>> resultFuture = salGroupsBatchService.updateGroupsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
Assert.assertEquals(43L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
Assert.assertEquals(45L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
inOrder.verify(salGroupService, Mockito.times(2)).updateGroup(updateGroupInputCpt.capture());
final List<UpdateGroupInput> allValues = updateGroupInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42, allValues.get(0).getOriginalGroup().getGroupId().getValue().longValue());
Assert.assertEquals(43, allValues.get(0).getUpdatedGroup().getGroupId().getValue().longValue());
Assert.assertEquals(44, allValues.get(1).getOriginalGroup().getGroupId().getValue().longValue());
Assert.assertEquals(45, allValues.get(1).getUpdatedGroup().getGroupId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Aggregations