Search in sources :

Example 11 with AddGroupInput

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

the class SalGroupsBatchServiceImplTest method testAddGroupsBatch_failure.

@Test
public void testAddGroupsBatch_failure() throws Exception {
    Mockito.when(salGroupService.addGroup(Mockito.<AddGroupInput>any())).thenReturn(RpcResultBuilder.<AddGroupOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupAddError").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.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)).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) AddGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInputBuilder) Test(org.junit.Test)

Example 12 with AddGroupInput

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

the class GroupConvertor method convert.

@Override
public GroupModInputBuilder convert(Group source, VersionDatapathIdConvertorData data) {
    GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
    if (source instanceof AddGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
    } else if (source instanceof RemoveGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
    } else if (source instanceof UpdatedGroup) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
    }
    if (GroupTypes.GroupAll.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTALL);
    }
    if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTSELECT);
    }
    if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
    }
    if (GroupTypes.GroupFf.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTFF);
    }
    groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
    // During group deletion do not push the buckets
    if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
        if (source.getBuckets() != null && source.getBuckets().getBucket().size() != 0) {
            Collections.sort(source.getBuckets().getBucket(), COMPARATOR);
            List<BucketsList> bucketLists = salToOFBucketList(source.getBuckets(), data.getVersion(), source.getGroupType().getIntValue(), data.getDatapathId());
            groupModInputBuilder.setBucketsList(bucketLists);
        }
    }
    groupModInputBuilder.setVersion(data.getVersion());
    return groupModInputBuilder;
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) UpdatedGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Aggregations

AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)12 Test (org.junit.Test)8 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)7 AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 AddGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)3 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)3 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)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 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)3 FRMTest (test.mock.util.FRMTest)3 SalGroupServiceMock (test.mock.util.SalGroupServiceMock)3 ArrayList (java.util.ArrayList)2 InOrder (org.mockito.InOrder)2 AddGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder)2