Add a test for unsupported criterion type
Change-Id: I0820b8f7fe9a375554721438284b5e9352c289b2
Showing
1 changed file
with
16 additions
and
2 deletions
... | @@ -31,9 +31,11 @@ import org.onosproject.net.flow.criteria.Criterion; | ... | @@ -31,9 +31,11 @@ import org.onosproject.net.flow.criteria.Criterion; |
31 | 31 | ||
32 | import com.fasterxml.jackson.databind.node.ObjectNode; | 32 | import com.fasterxml.jackson.databind.node.ObjectNode; |
33 | 33 | ||
34 | -import static org.onlab.junit.TestUtils.getField; | ||
35 | import static org.hamcrest.MatcherAssert.assertThat; | 34 | import static org.hamcrest.MatcherAssert.assertThat; |
36 | -import static org.hamcrest.Matchers.*; | 35 | +import static org.hamcrest.Matchers.is; |
36 | +import static org.hamcrest.Matchers.notNullValue; | ||
37 | +import static org.onlab.junit.TestUtils.getField; | ||
38 | +import static org.onlab.junit.TestUtils.setField; | ||
37 | import static org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion; | 39 | import static org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion; |
38 | 40 | ||
39 | /** | 41 | /** |
... | @@ -418,4 +420,16 @@ public class CriterionCodecTest { | ... | @@ -418,4 +420,16 @@ public class CriterionCodecTest { |
418 | assertThat(result, matchesCriterion(criterion)); | 420 | assertThat(result, matchesCriterion(criterion)); |
419 | } | 421 | } |
420 | 422 | ||
423 | + /** | ||
424 | + * Tests that an unimplemented criterion type only returns the type and | ||
425 | + * no other data. | ||
426 | + */ | ||
427 | + @Test | ||
428 | + public void matchUnknownTypeTest() throws Exception { | ||
429 | + Criterion criterion = Criteria.matchOpticalSignalType((byte) 250); | ||
430 | + setField(criterion, "type", Criterion.Type.UNASSIGNED_40); | ||
431 | + ObjectNode result = criterionCodec.encode(criterion, context); | ||
432 | + assertThat(result.get("type").textValue(), is(criterion.type().toString())); | ||
433 | + assertThat(result.size(), is(1)); | ||
434 | + } | ||
421 | } | 435 | } | ... | ... |
-
Please register or login to post a comment