use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImplTest method testRemoveGroupsBatch_success.
@Test
public void testRemoveGroupsBatch_success() throws Exception {
Mockito.when(salGroupService.removeGroup(Mockito.<RemoveGroupInput>any())).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().build()).buildFuture());
final RemoveGroupsBatchInput input = new RemoveGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveGroups(Lists.newArrayList(createEmptyBatchRemoveGroup(42L), createEmptyBatchRemoveGroup(43L))).build();
final Future<RpcResult<RemoveGroupsBatchOutput>> resultFuture = salGroupsBatchService.removeGroupsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertTrue(resultFuture.get().isSuccessful());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
inOrder.verify(salGroupService, Mockito.times(2)).removeGroup(removeGroupInputCpt.capture());
final List<RemoveGroupInput> allValues = removeGroupInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42L, allValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(43L, allValues.get(1).getGroupId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder in project openflowplugin by opendaylight.
the class GroupForwarderTest method testRemove.
@Test
public void testRemove() throws Exception {
Mockito.when(salGroupService.removeGroup(removeGroupInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().setTransactionId(txId).build()).buildFuture());
final Future<RpcResult<RemoveGroupOutput>> addResult = groupForwarder.remove(groupPath, group, flowCapableNodePath);
Mockito.verify(salGroupService).removeGroup(Matchers.<RemoveGroupInput>any());
Assert.assertTrue(addResult.isDone());
final RpcResult<RemoveGroupOutput> result = addResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(1, result.getResult().getTransactionId().getValue().intValue());
final RemoveGroupInput removeGroupInput = removeGroupInputCpt.getValue();
Assert.assertEquals(groupPath, removeGroupInput.getGroupRef().getValue());
Assert.assertNull(removeGroupInput.getBuckets());
Assert.assertEquals(nodePath, removeGroupInput.getNode().getValue());
Assert.assertEquals("test-group", removeGroupInput.getGroupName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantGroups.
@Test
public void testRemoveRedundantGroups() throws Exception {
Mockito.when(groupCommitter.remove(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().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.removeRedundantGroups(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(5L, 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(2L, groupCaptorAllValues.get(3).getGroupId().getValue().longValue());
final InOrder inOrderGroup = Mockito.inOrder(flowCapableTxService, groupCommitter);
// remove 5
inOrderGroup.verify(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// remove 3, 4
inOrderGroup.verify(groupCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// remove 2
inOrderGroup.verify(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderGroup.verifyNoMoreInteractions();
}
Aggregations