Search in sources :

Example 1 with UpdateMeterOutputBuilder

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

the class MeterForwarderTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    Mockito.when(salMeterService.updateMeter(updateMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
    Meter meterOriginal = new MeterBuilder(meter).build();
    Meter meterUpdate = new MeterBuilder(meter).setMeterName("another-test").build();
    final Future<RpcResult<UpdateMeterOutput>> updateResult = meterForwarder.update(meterPath, meterOriginal, meterUpdate, flowCapableNodePath);
    Mockito.verify(salMeterService).updateMeter(Matchers.<UpdateMeterInput>any());
    Assert.assertTrue(updateResult.isDone());
    final RpcResult<UpdateMeterOutput> meterResult = updateResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(meterResult.isSuccessful());
    Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
    final UpdateMeterInput updateMeterInput = updateMeterInputCpt.getValue();
    Assert.assertEquals(meterPath, updateMeterInput.getMeterRef().getValue());
    Assert.assertEquals(nodePath, updateMeterInput.getNode().getValue());
    Assert.assertEquals("test-meter", updateMeterInput.getOriginalMeter().getMeterName());
    Assert.assertEquals("another-test", updateMeterInput.getUpdatedMeter().getMeterName());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) UpdateMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) Test(org.junit.Test)

Example 2 with UpdateMeterOutputBuilder

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

the class SalMetersBatchServiceImplTest method testUpdateMetersBatch_success.

@Test
public void testUpdateMetersBatch_success() throws Exception {
    Mockito.when(salMeterService.updateMeter(Mockito.<UpdateMeterInput>any())).thenReturn(RpcResultBuilder.success(new UpdateMeterOutputBuilder().build()).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.assertTrue(resultFuture.get().isSuccessful());
    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) UpdateMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) Test(org.junit.Test)

Example 3 with UpdateMeterOutputBuilder

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

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingMeters_withUpdate.

@Test
public void testAddMissingMeters_withUpdate() throws Exception {
    Mockito.when(meterCommitter.add(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddMeterOutputBuilder().build()).buildFuture());
    Mockito.when(meterCommitter.update(Matchers.<InstanceIdentifier<Meter>>any(), meterUpdateCaptor.capture(), meterUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateMeterOutputBuilder().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.addMissingMeters(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 List<Meter> meterUpdateCaptorAllValues = meterUpdateCaptor.getAllValues();
    Assert.assertEquals(2, meterUpdateCaptorAllValues.size());
    Assert.assertEquals(1L, meterUpdateCaptorAllValues.get(0).getMeterId().getValue().longValue());
    Assert.assertEquals(1L, meterUpdateCaptorAllValues.get(1).getMeterId().getValue().longValue());
    final InOrder inOrderMeters = Mockito.inOrder(flowCapableTxService, meterCommitter);
    inOrderMeters.verify(meterCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    inOrderMeters.verify(meterCommitter).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    // TODO: uncomment when enabled in impl
    // inOrderMeters.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderMeters.verifyNoMoreInteractions();
}
Also used : 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) UpdateMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder) AddMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 UpdateMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder)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 UpdateMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput)2 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)1 AddMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder)1 UpdateMeterOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput)1 UpdateMetersBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput)1 UpdateMetersBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInputBuilder)1