Search in sources :

Example 6 with RemoveMeterInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput 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());
}
Also used : InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveMetersBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput) RemoveMetersBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) Test(org.junit.Test)

Example 7 with RemoveMeterInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput in project openflowplugin by opendaylight.

the class SalMeterServiceImplTest method removeMeter.

private void removeMeter() throws Exception {
    final MeterId dummyMeterId = new MeterId(DUMMY_METER_ID);
    RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder().setMeterId(dummyMeterId).build();
    this.<RemoveMeterOutput>mockSuccessfulFuture();
    salMeterService.removeMeter(removeMeterInput);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) RemoveMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)

Aggregations

RemoveMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)7 Test (org.junit.Test)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 RemoveMeterOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput)3 ArrayList (java.util.ArrayList)2 InOrder (org.mockito.InOrder)2 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)2 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)2 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)2 RemoveMeterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder)2 RemoveMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 RemoveMetersBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput)2 RemoveMetersBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)1 StaleMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter)1 StaleMeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder)1