Search in sources :

Example 1 with SalMeterServiceMock

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());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 2 with SalMeterServiceMock

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());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 3 with SalMeterServiceMock

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());
}
Also used : MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)3 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)3 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)3 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)3 StaleMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter)3 StaleMeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder)3 StaleMeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey)3 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)3 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)3 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)3 FRMTest (test.mock.util.FRMTest)3 SalMeterServiceMock (test.mock.util.SalMeterServiceMock)3 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 RemoveMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)1 UpdateMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput)1