use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testExecuteSyncStrategy.
@Test
public void testExecuteSyncStrategy() throws Exception {
final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
final SyncCrudCounters syncCounters = new SyncCrudCounters();
final ListenableFuture<RpcResult<Void>> rpcResult = syncPlanPushStrategy.executeSyncStrategy(RpcResultBuilder.<Void>success().buildFuture(), diffInput, syncCounters);
Mockito.verify(groupCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(groupCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(groupCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(flowCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(flowCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(flowCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(meterCommitter, Mockito.times(3)).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(meterCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.verify(meterCommitter, Mockito.times(3)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Assert.assertTrue(rpcResult.isDone());
Assert.assertTrue(rpcResult.get().isSuccessful());
Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getAdded());
Assert.assertEquals(3, syncCounters.getFlowCrudCounts().getUpdated());
Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getRemoved());
Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getAdded());
Assert.assertEquals(3, syncCounters.getGroupCrudCounts().getUpdated());
Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getRemoved());
Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getAdded());
Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getUpdated());
Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getRemoved());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterNotificationSupplierImpl method deleteNotification.
@Override
public MeterRemoved deleteNotification(final InstanceIdentifier<Meter> path) {
Preconditions.checkArgument(path != null);
final MeterRemovedBuilder builder = new MeterRemovedBuilder();
builder.setMeterId(path.firstKeyOf(Meter.class, MeterKey.class).getMeterId());
builder.setMeterRef(new MeterRef(path));
builder.setNode(createNodeRef(path));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterNotificationSupplierImpl method createNotification.
@Override
public MeterAdded createNotification(final Meter dataTreeItemObject, final InstanceIdentifier<Meter> path) {
Preconditions.checkArgument(dataTreeItemObject != null);
Preconditions.checkArgument(path != null);
final MeterAddedBuilder builder = new MeterAddedBuilder(dataTreeItemObject);
builder.setMeterRef(new MeterRef(path));
builder.setNode(createNodeRef(path));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterNotificationSupplierImplTest method testCreateChangeEvent.
@Test
public void testCreateChangeEvent() {
final TestData testData = new TestData(createTestMeterPath(), null, createTestMeter(), DataObjectModification.ModificationType.WRITE);
Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
verify(notifProviderService, times(1)).publish(Matchers.any(MeterAdded.class));
}
Aggregations