16 package org.openkilda.atdd.staging.steps;
18 import static java.lang.String.format;
19 import static org.hamcrest.MatcherAssert.assertThat;
20 import static org.hamcrest.Matchers.empty;
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertTrue;
28 import cucumber.api.java.en.Given;
29 import cucumber.api.java8.En;
30 import lombok.extern.slf4j.Slf4j;
31 import org.springframework.beans.factory.annotation.Autowired;
45 @Given(
"^a clean topology with no flows and no discrepancies in switch rules and meters")
47 northboundService.deleteAllFlows();
48 assertTrue(northboundService.getAllFlows().isEmpty());
50 topologyDefinition.getActiveSwitches().stream()
51 .peek(sw -> northboundService.deleteSwitchRules(sw.getDpId()))
52 .map(sw -> northboundService.synchronizeSwitchRules(sw.getDpId()))
53 .forEach(rulesSyncResult -> {
54 assertThat(rulesSyncResult.getExcessRules(), empty());
56 rulesSyncResult.getMissingRules().size() - rulesSyncResult.getInstalledRules().size());
59 topologyDefinition.getActiveSwitches()
62 assertThat(
format(
"Switch %s has unexpected meters installed", sw),
63 floodlightService.getMeters(sw.getDpId()).values(), empty());
64 }
catch (UnsupportedOperationException ex) {
66 log.warn(
"Switch {} doesn't support dumping of meters. {}", sw.getDpId(), ex.getMessage());
void cleanupFlowsAndSwitches()