Due to a ransomware attack, the wiki was reverted to a July 2022 version. . We apologize for the lack of a more recent valid backup.
...
Code Block | ||||
---|---|---|---|---|
| ||||
/** * Hamcrest matcher to check that a selector contains a * Criterion with the specified type. */ public static final class CriterionExistsMatcher extends TypeSafeMatcher<TrafficSelector> { private final Criterion.Type type; /** * Constructs a matcher for the given criterion type. * * @param typeValue criterion type to match */ public CriterionExistsMatcher(Criterion.Type typeValue) { type = typeValue; } @Override public boolean matchesSafely(TrafficSelector selector) { final Set<Criterion> criteria = selector.criteria(); return notNullValue().matches(criteria) && hasSize(1).matches(criteria) && notNullValue().matches(selector.getCriterion(type)); } @Override public void describeTo(Description description) { description.appendText("a criterion with type \" "). appendText(type.toString()). appendText("\""); } } /** * Creates a criterion type matcher. Returns a matcher * for a criterion with the given type. * * @param type type of Criterion to match * @return Matcher object */ @Factory public static Matcher<TrafficSelector> hasCriterionWithType(Criterion.Type type) { return new CriterionExistsMatcher(type); } /** * Tests the builder functions that add specific criteria. */ @Test public void testCriteriaCreation() { TrafficSelector selector; selector = DefaultTrafficSelector.builder() .matchInport(PortNumber.portNumber(11)).build(); assertThat(selector, hasCriterionWithType(Type.IN_PORT)); } |
...
Home : Contributing to the ONOS Codebase
...