use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder in project openflowplugin by opendaylight.
the class SalMetersBatchServiceImplTest method testRemoveMetersBatch_success.
@Test
public void testRemoveMetersBatch_success() throws Exception {
Mockito.when(salMeterService.removeMeter(Mockito.<RemoveMeterInput>any())).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().build()).buildFuture());
final RemoveMetersBatchInput input = new RemoveMetersBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveMeters(Lists.newArrayList(createEmptyBatchRemoveMeter(42L), createEmptyBatchRemoveMeter(43L))).build();
final Future<RpcResult<RemoveMetersBatchOutput>> resultFuture = salMetersBatchService.removeMetersBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertTrue(resultFuture.get().isSuccessful());
final InOrder inOrder = Mockito.inOrder(salMeterService, transactionService);
inOrder.verify(salMeterService, Mockito.times(2)).removeMeter(removeMeterInputCpt.capture());
final List<RemoveMeterInput> allValues = removeMeterInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42L, allValues.get(0).getMeterId().getValue().longValue());
Assert.assertEquals(43L, allValues.get(1).getMeterId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method adaptFlatBatchRemoveMeter.
/**
* Adapt flat batch remove meter.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.meters.service.rev160316.SalMetersBatchService#removeMetersBatch(RemoveMetersBatchInput)}
*/
public static RemoveMetersBatchInput adaptFlatBatchRemoveMeter(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchRemoveMeters> batchMeters = new ArrayList<>();
for (FlatBatchRemoveMeter batchRemoveMeter : planStep.<FlatBatchRemoveMeter>getTaskBag()) {
final BatchRemoveMeters removeMeters = new BatchRemoveMetersBuilder(batchRemoveMeter).setMeterId(batchRemoveMeter.getMeterId()).build();
batchMeters.add(removeMeters);
}
return new RemoveMetersBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchRemoveMeters(batchMeters).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder in project openflowplugin by opendaylight.
the class SalMetersBatchServiceImplTest method testRemoveMetersBatch_failure.
@Test
public void testRemoveMetersBatch_failure() throws Exception {
Mockito.when(salMeterService.removeMeter(Mockito.<RemoveMeterInput>any())).thenReturn(RpcResultBuilder.<RemoveMeterOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupRemoveError").buildFuture());
final RemoveMetersBatchInput input = new RemoveMetersBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveMeters(Lists.newArrayList(createEmptyBatchRemoveMeter(42L), createEmptyBatchRemoveMeter(43L))).build();
final Future<RpcResult<RemoveMetersBatchOutput>> resultFuture = salMetersBatchService.removeMetersBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size());
Assert.assertEquals(42L, resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue());
Assert.assertEquals(43L, 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)).removeMeter(removeMeterInputCpt.capture());
final List<RemoveMeterInput> allValues = removeMeterInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42L, allValues.get(0).getMeterId().getValue().longValue());
Assert.assertEquals(43L, allValues.get(1).getMeterId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Aggregations