Search in sources :

Example 1 with AddGroupOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingGroups.

@Test
public void testAddMissingGroups() throws Exception {
    Mockito.when(groupCommitter.add(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().build()).buildFuture());
    ItemSyncBox<Group> groupBox1 = new ItemSyncBox<>();
    groupBox1.getItemsToPush().add(DSInputFactory.createGroup(2L));
    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 InOrder inOrderGroups = Mockito.inOrder(flowCapableTxService, groupCommitter);
    // add 2
    inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<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();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder) Test(org.junit.Test)

Example 2 with AddGroupOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder in project openflowplugin by opendaylight.

the class SalGroupsBatchServiceImplTest method testAddGroupsBatch_success.

@Test
public void testAddGroupsBatch_success() throws Exception {
    Mockito.when(salGroupService.addGroup(Mockito.<AddGroupInput>any())).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().build()).buildFuture());
    final AddGroupsBatchInput input = new AddGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchAddGroups(Lists.newArrayList(createEmptyBatchAddGroup(42L), createEmptyBatchAddGroup(43L))).build();
    final Future<RpcResult<AddGroupsBatchOutput>> resultFuture = salGroupsBatchService.addGroupsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertTrue(resultFuture.get().isSuccessful());
    final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
    inOrder.verify(salGroupService, Mockito.times(2)).addGroup(addGroupInputCpt.capture());
    final List<AddGroupInput> allValues = addGroupInputCpt.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 : InOrder(org.mockito.InOrder) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) AddGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder) AddGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInputBuilder) Test(org.junit.Test)

Example 3 with AddGroupOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder in project openflowplugin by opendaylight.

the class GroupForwarderTest method testAdd.

@Test
public void testAdd() throws Exception {
    Mockito.when(salGroupService.addGroup(addGroupInputCpt.capture())).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().setTransactionId(txId).build()).buildFuture());
    final Future<RpcResult<AddGroupOutput>> addResult = groupForwarder.add(groupPath, group, flowCapableNodePath);
    Mockito.verify(salGroupService).addGroup(Matchers.<AddGroupInput>any());
    Assert.assertTrue(addResult.isDone());
    final RpcResult<AddGroupOutput> result = addResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(result.isSuccessful());
    Assert.assertEquals(1, result.getResult().getTransactionId().getValue().intValue());
    final AddGroupInput addGroupInput = addGroupInputCpt.getValue();
    Assert.assertEquals(groupPath, addGroupInput.getGroupRef().getValue());
    Assert.assertEquals(nodePath, addGroupInput.getNode().getValue());
    Assert.assertNotNull(addGroupInput.getBuckets());
    Assert.assertEquals("test-group", addGroupInput.getGroupName());
}
Also used : AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder) Test(org.junit.Test)

Example 4 with AddGroupOutputBuilder

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

Aggregations

Test (org.junit.Test)4 AddGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 InOrder (org.mockito.InOrder)3 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)2 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)2 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)2 AddGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput)1 UpdateGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder)1 AddGroupsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInput)1 AddGroupsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInputBuilder)1