Search in sources :

Example 1 with RemoveMeterOutputBuilder

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

the class MeterForwarderTest method testRemove.

@Test
public void testRemove() throws Exception {
    Mockito.when(salMeterService.removeMeter(removeMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
    Meter removeMeter = new MeterBuilder(meter).build();
    final Future<RpcResult<RemoveMeterOutput>> removeResult = meterForwarder.remove(meterPath, removeMeter, flowCapableNodePath);
    Mockito.verify(salMeterService).removeMeter(Matchers.<RemoveMeterInput>any());
    Assert.assertTrue(removeResult.isDone());
    final RpcResult<RemoveMeterOutput> meterResult = removeResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(meterResult.isSuccessful());
    Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
    final RemoveMeterInput removeMeterInput = removeMeterInputCpt.getValue();
    Assert.assertEquals(meterPath, removeMeterInput.getMeterRef().getValue());
    Assert.assertEquals(nodePath, removeMeterInput.getNode().getValue());
    Assert.assertEquals("test-meter", removeMeterInput.getMeterName());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) RemoveMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) Test(org.junit.Test)

Example 2 with RemoveMeterOutputBuilder

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

the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantMeters.

@Test
public void testRemoveRedundantMeters() throws Exception {
    Mockito.when(meterCommitter.remove(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().build()).buildFuture());
    final ItemSyncBox<Meter> meterSyncBox = new ItemSyncBox<>();
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(2L));
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(4L));
    meterSyncBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createMeter(1L), DSInputFactory.createMeterWithBody(1L)));
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.removeRedundantMeters(NODE_ID, NODE_IDENT, meterSyncBox, counters);
    Assert.assertTrue(result.isDone());
    Assert.assertTrue(result.get().isSuccessful());
    final List<Meter> metercaptorAllValues = meterCaptor.getAllValues();
    Assert.assertEquals(2, metercaptorAllValues.size());
    Assert.assertEquals(2L, metercaptorAllValues.get(0).getMeterId().getValue().longValue());
    Assert.assertEquals(4L, metercaptorAllValues.get(1).getMeterId().getValue().longValue());
    final InOrder inOrderMeter = Mockito.inOrder(flowCapableTxService, meterCommitter);
    inOrderMeter.verify(meterCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    // TODO: uncomment when enabled in impl
    // inOrderMeter.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderMeter.verifyNoMoreInteractions();
}
Also used : RemoveMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder) InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 3 with RemoveMeterOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder 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());
}
Also used : RemoveMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder) 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)

Aggregations

Test (org.junit.Test)3 RemoveMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 InOrder (org.mockito.InOrder)2 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)2 RemoveMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)2 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)1 RemoveMeterOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput)1 RemoveMetersBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput)1 RemoveMetersBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder)1