use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder in project openflowplugin by opendaylight.
the class GroupForwarderTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Mockito.when(salGroupService.updateGroup(updateGroupInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().setTransactionId(txId).build()).buildFuture());
Group groupOriginal = new GroupBuilder(group).build();
Group groupUpdate = new GroupBuilder(group).setGroupName("another-test").build();
final Future<RpcResult<UpdateGroupOutput>> addResult = groupForwarder.update(groupPath, groupOriginal, groupUpdate, flowCapableNodePath);
Mockito.verify(salGroupService).updateGroup(Matchers.<UpdateGroupInput>any());
Assert.assertTrue(addResult.isDone());
final RpcResult<UpdateGroupOutput> result = addResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(1, result.getResult().getTransactionId().getValue().intValue());
final UpdateGroupInput updateGroupInput = updateGroupInputCpt.getValue();
Assert.assertEquals(groupPath, updateGroupInput.getGroupRef().getValue());
Assert.assertEquals(nodePath, updateGroupInput.getNode().getValue());
Assert.assertNotNull(updateGroupInput.getOriginalGroup().getBuckets());
Assert.assertNotNull(updateGroupInput.getUpdatedGroup().getBuckets());
Assert.assertEquals("test-group", updateGroupInput.getOriginalGroup().getGroupName());
Assert.assertEquals("another-test", updateGroupInput.getUpdatedGroup().getGroupName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingGroups_withUpdate.
@Test
public void testAddMissingGroups_withUpdate() throws Exception {
Mockito.when(groupCommitter.add(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().build()).buildFuture());
Mockito.when(groupCommitter.update(Matchers.<InstanceIdentifier<Group>>any(), groupUpdateCaptor.capture(), groupUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().build()).buildFuture());
ItemSyncBox<Group> groupBox1 = new ItemSyncBox<>();
groupBox1.getItemsToPush().add(DSInputFactory.createGroup(2L));
groupBox1.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createGroup(1L), DSInputFactory.createGroupWithAction(1L)));
ItemSyncBox<Group> groupBox2 = new ItemSyncBox<>();
groupBox2.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(3L, 2L));
groupBox2.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(4L, 2L));
ItemSyncBox<Group> groupBox3 = new ItemSyncBox<>();
groupBox3.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(5L, 3L, 4L));
final List<ItemSyncBox<Group>> groupBoxLot = Lists.newArrayList(groupBox1, groupBox2, groupBox3);
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingGroups(NODE_ID, NODE_IDENT, groupBoxLot, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Group> groupCaptorAllValues = groupCaptor.getAllValues();
Assert.assertEquals(4, groupCaptorAllValues.size());
Assert.assertEquals(2L, groupCaptorAllValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(3L, groupCaptorAllValues.get(1).getGroupId().getValue().longValue());
Assert.assertEquals(4L, groupCaptorAllValues.get(2).getGroupId().getValue().longValue());
Assert.assertEquals(5L, groupCaptorAllValues.get(3).getGroupId().getValue().longValue());
final List<Group> groupUpdateCaptorAllValues = groupUpdateCaptor.getAllValues();
Assert.assertEquals(2, groupUpdateCaptorAllValues.size());
Assert.assertEquals(1L, groupUpdateCaptorAllValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(1L, groupUpdateCaptorAllValues.get(1).getGroupId().getValue().longValue());
final InOrder inOrderGroups = Mockito.inOrder(flowCapableTxService, groupCommitter);
// add 2, update 1
inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(groupCommitter).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// add 3, 4
inOrderGroups.verify(groupCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// add 5
inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderGroups.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder 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());
}
Aggregations