use of test.mock.util.SalMeterServiceMock in project openflowplugin by opendaylight.
the class MeterListenerTest method removeMeterTest.
@Test
public void removeMeterTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<RemoveMeterInput> removeMeterCalls = salMeterService.getRemoveMeterCalls();
assertEquals(1, removeMeterCalls.size());
assertEquals("DOM-1", removeMeterCalls.get(0).getTransactionUri().getValue());
assertEquals(meterII, removeMeterCalls.get(0).getMeterRef().getValue());
}
use of test.mock.util.SalMeterServiceMock in project openflowplugin by opendaylight.
the class MeterListenerTest method updateMeterTest.
@Test
public void updateMeterTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").setBarrier(false).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<UpdateMeterInput> updateMeterCalls = salMeterService.getUpdateMeterCalls();
assertEquals(1, updateMeterCalls.size());
assertEquals("DOM-1", updateMeterCalls.get(0).getTransactionUri().getValue());
assertEquals(meterII, updateMeterCalls.get(0).getMeterRef().getValue());
}
use of test.mock.util.SalMeterServiceMock in project openflowplugin by opendaylight.
the class MeterListenerTest method addTwoMetersTest.
@Test
public void addTwoMetersTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
meterKey = new MeterKey(new MeterId((long) 2001));
meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(2, addMeterCalls.size());
assertEquals("DOM-1", addMeterCalls.get(1).getTransactionUri().getValue());
assertEquals(meterII, addMeterCalls.get(1).getMeterRef().getValue());
}
Aggregations