Search in sources :

Example 26 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput 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 27 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput 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 28 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput 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 29 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput 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 30 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class SalMetersBatchServiceImplTest method testUpdateMetersBatch_failure.

@Test
public void testUpdateMetersBatch_failure() throws Exception {
    Mockito.when(salMeterService.updateMeter(Mockito.<UpdateMeterInput>any())).thenReturn(RpcResultBuilder.<UpdateMeterOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ur-groupUpdateError").buildFuture());
    final UpdateMetersBatchInput input = new UpdateMetersBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateMeters(Lists.newArrayList(createEmptyBatchUpdateMeter(42L), createEmptyBatchUpdateMeter(44L))).build();
    final Future<RpcResult<UpdateMetersBatchOutput>> resultFuture = salMetersBatchService.updateMetersBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertFalse(resultFuture.get().isSuccessful());
    Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size());
    Assert.assertEquals(43L, resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue());
    Assert.assertEquals(45L, resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue());
    Assert.assertEquals(2, resultFuture.get().getErrors().size());
    final InOrder inOrder = Mockito.inOrder(salMeterService, transactionService);
    inOrder.verify(salMeterService, Mockito.times(2)).updateMeter(updateMeterInputCpt.capture());
    final List<UpdateMeterInput> allValues = updateMeterInputCpt.getAllValues();
    Assert.assertEquals(2, allValues.size());
    Assert.assertEquals(42, allValues.get(0).getOriginalMeter().getMeterId().getValue().longValue());
    Assert.assertEquals(43, allValues.get(0).getUpdatedMeter().getMeterId().getValue().longValue());
    Assert.assertEquals(44, allValues.get(1).getOriginalMeter().getMeterId().getValue().longValue());
    Assert.assertEquals(45, allValues.get(1).getUpdatedMeter().getMeterId().getValue().longValue());
    inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : UpdateMetersBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateMetersBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInputBuilder) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 InOrder (org.mockito.InOrder)27 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)9 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)4 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 SendBarrierInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput)4 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)4 LinkedHashMap (java.util.LinkedHashMap)3 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)3 AddFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder)3 AddGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder)3 AddMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)2 RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)2 RemoveFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder)2 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)2 UpdateFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder)2 AddFlowsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput)2