Search in sources :

Example 1 with SalGroupService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService 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());
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Test(org.junit.Test)

Example 2 with SalGroupService

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

the class GroupForwarderTest method setUp.

@Before
public void setUp() throws Exception {
    groupForwarder = new GroupForwarder(salGroupService);
    txId = new TransactionId(BigInteger.ONE);
}
Also used : TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Before(org.junit.Before)

Example 3 with SalGroupService

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

the class GroupListenerTest method addTwoGroupsTest.

@Test
public void addTwoGroupsTest() throws Exception {
    addFlowCapableNode(NODE_KEY);
    GroupKey groupKey = new GroupKey(new GroupId((long) 255));
    InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
    Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
    assertEquals(1, addGroupCalls.size());
    assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
    groupKey = new GroupKey(new GroupId((long) 256));
    groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
    group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    addGroupCalls = salGroupService.getAddGroupCalls();
    assertEquals(2, addGroupCalls.size());
    assertEquals("DOM-1", addGroupCalls.get(1).getTransactionUri().getValue());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) StaleGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) StaleGroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey) SalGroupServiceMock(test.mock.util.SalGroupServiceMock) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 4 with SalGroupService

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

the class GroupListenerTest method updateGroupTest.

@Test
public void updateGroupTest() throws Exception {
    addFlowCapableNode(NODE_KEY);
    GroupKey groupKey = new GroupKey(new GroupId((long) 255));
    InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
    Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
    assertEquals(1, addGroupCalls.size());
    assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
    group = new GroupBuilder().setKey(groupKey).setGroupName("Group2").build();
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    List<UpdateGroupInput> updateGroupCalls = salGroupService.getUpdateGroupCalls();
    assertEquals(1, updateGroupCalls.size());
    assertEquals("DOM-1", updateGroupCalls.get(0).getTransactionUri().getValue());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) StaleGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) StaleGroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey) SalGroupServiceMock(test.mock.util.SalGroupServiceMock) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 5 with SalGroupService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService 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)

Aggregations

Test (org.junit.Test)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 InOrder (org.mockito.InOrder)6 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)6 RemoveGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput)4 UpdateGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput)4 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)4 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)3 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)3 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)3 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)3 StaleGroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder)3 StaleGroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey)3 FRMTest (test.mock.util.FRMTest)3 SalGroupServiceMock (test.mock.util.SalGroupServiceMock)3 AddGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder)2 RemoveGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder)2