use of org.openkilda.testing.service.floodlight.model.MeterEntry in project open-kilda by telstra.
the class FlowSteps method doesNotHaveMeter.
@Then("^meters '(.*)' does not have '(.*)'$")
public void doesNotHaveMeter(String metersAlias, String meterAlias) {
MetersEntriesMap meters = topologyUnderTest.getAliasedObject(metersAlias);
Entry<Integer, MeterEntry> meter = topologyUnderTest.getAliasedObject(meterAlias);
assertFalse(meters.containsKey(meter.getKey()));
}
use of org.openkilda.testing.service.floodlight.model.MeterEntry in project open-kilda by telstra.
the class FlowSteps method selectFirstMeter.
@And("^select first meter of '(.*)' and alias it as '(.*)'$")
public void selectFirstMeter(String metersAlias, String newMeterAlias) {
MetersEntriesMap meters = topologyUnderTest.getAliasedObject(metersAlias);
Entry<Integer, MeterEntry> firstMeter = meters.entrySet().iterator().next();
topologyUnderTest.addAlias(newMeterAlias, firstMeter);
}
use of org.openkilda.testing.service.floodlight.model.MeterEntry in project open-kilda by telstra.
the class StubServiceFactory method getFloodlightStub.
/**
* Get a stub for {@link FloodlightService}. The instance is tied to the factory state.
*/
public FloodlightService getFloodlightStub() {
FloodlightService serviceMock = mock(FloodlightService.class);
when(serviceMock.getFlows(any())).thenAnswer(invocation -> {
SwitchId switchId = (SwitchId) invocation.getArguments()[0];
String switchVersion = topologyDefinition.getActiveSwitches().stream().filter(sw -> sw.getDpId().equals(switchId)).map(Switch::getOfVersion).findAny().orElse("OF_13");
return buildFlowEntries(switchId, switchVersion);
});
when(serviceMock.getMeters(any())).then((Answer<MetersEntriesMap>) invocation -> {
SwitchId switchId = (SwitchId) invocation.getArguments()[0];
MetersEntriesMap result = new MetersEntriesMap();
flows.values().forEach(flowPair -> {
if (flowPair.getLeft().getSourceSwitch().equals(switchId) || flowPair.getRight().getSourceSwitch().equals(switchId)) {
MeterEntry entry = new MeterEntry(emptyList(), flowPair.getLeft().getMeterId(), singletonList(new MeterBand(flowPair.getLeft().getBandwidth(), 0, "", 1)), "");
result.put(entry.getMeterId(), entry);
}
});
return result;
});
when(serviceMock.getSwitches()).then((Answer<List<SwitchEntry>>) invocation -> topologyDefinition.getActiveSwitches().stream().map(sw -> SwitchEntry.builder().switchId(sw.getDpId()).ofVersion(sw.getOfVersion()).build()).collect(toList()));
return serviceMock;
}
Aggregations