Add a test for unsupported criterion type
Change-Id: I0820b8f7fe9a375554721438284b5e9352c289b2
diff --git a/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java b/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
index a7f6bd2..873424b 100644
--- a/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
+++ b/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
@@ -31,9 +31,11 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
-import static org.onlab.junit.TestUtils.getField;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.TestUtils.getField;
+import static org.onlab.junit.TestUtils.setField;
import static org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion;
/**
@@ -418,4 +420,16 @@
assertThat(result, matchesCriterion(criterion));
}
+ /**
+ * Tests that an unimplemented criterion type only returns the type and
+ * no other data.
+ */
+ @Test
+ public void matchUnknownTypeTest() throws Exception {
+ Criterion criterion = Criteria.matchOpticalSignalType((byte) 250);
+ setField(criterion, "type", Criterion.Type.UNASSIGNED_40);
+ ObjectNode result = criterionCodec.encode(criterion, context);
+ assertThat(result.get("type").textValue(), is(criterion.type().toString()));
+ assertThat(result.size(), is(1));
+ }
}