Search in sources :

Example 1 with RemoveGroupOutputBuilder

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());
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) RemoveGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder) RemoveGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput) Test(org.junit.Test)

Example 2 with RemoveGroupOutputBuilder

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());
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) RemoveGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder) RemoveGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 3 with RemoveGroupOutputBuilder

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();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) RemoveGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder) InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 RemoveGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 InOrder (org.mockito.InOrder)2 RemoveGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput)2 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 RemoveGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput)1 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)1 RemoveGroupsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput)1 RemoveGroupsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInputBuilder)1