Search in sources :

Example 11 with SalGroupService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService 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());
}
Also used : UpdateGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder) UpdateGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Test(org.junit.Test)

Example 12 with SalGroupService

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

the class SalGroupsBatchServiceImplTest method testUpdateGroupsBatch_failure.

@Test
public void testUpdateGroupsBatch_failure() throws Exception {
    Mockito.when(salGroupService.updateGroup(Mockito.<UpdateGroupInput>any())).thenReturn(RpcResultBuilder.<UpdateGroupOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ur-groupUpdateError").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.assertFalse(resultFuture.get().isSuccessful());
    Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
    Assert.assertEquals(43L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
    Assert.assertEquals(45L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
    Assert.assertEquals(2, resultFuture.get().getErrors().size());
    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());
}
Also used : UpdateGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Test(org.junit.Test)

Example 13 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_failure.

@Test
public void testRemoveGroupsBatch_failure() throws Exception {
    Mockito.when(salGroupService.removeGroup(Mockito.<RemoveGroupInput>any())).thenReturn(RpcResultBuilder.<RemoveGroupOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupRemoveError").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.assertFalse(resultFuture.get().isSuccessful());
    Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
    Assert.assertEquals(42L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
    Assert.assertEquals(43L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
    Assert.assertEquals(2, resultFuture.get().getErrors().size());
    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) 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 14 with SalGroupService

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

the class OpenflowpluginGroupTestServiceProvider method register.

public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(final ProviderContext ctx) {
    RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx.<SalGroupService>addRoutedRpcImplementation(SalGroupService.class, this);
    setGroupRegistration(addRoutedRpcImplementation);
    InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
    NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
    InstanceIdentifier<Node> instance = nodeIndentifier.build();
    groupRegistration.registerPath(NodeContext.class, instance);
    RoutedRpcRegistration<SalGroupService> groupRegistration1 = this.getGroupRegistration();
    return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {

        @Override
        protected void removeRegistration() {
            groupRegistration1.close();
        }
    };
}
Also used : AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) SalGroupService(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

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