Add unit tests to increase sonar coverage
[aai/data-router.git] / src / test / java / org / onap / aai / datarouter / exception / DataRouterExceptionTest.java
diff --git a/src/test/java/org/onap/aai/datarouter/exception/DataRouterExceptionTest.java b/src/test/java/org/onap/aai/datarouter/exception/DataRouterExceptionTest.java
new file mode 100644 (file)
index 0000000..ecf845c
--- /dev/null
@@ -0,0 +1,51 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.datarouter.exception;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+import javax.ws.rs.core.Response;\r
+\r
+public class DataRouterExceptionTest {\r
+\r
+    @Test\r
+    public void testDataRouterError(){\r
+        DataRouterError error1 = DataRouterError.DL_PARSE_100;\r
+        Assert.assertEquals("DL-100", error1.getId());\r
+        Assert.assertNotNull(error1.getMessage());\r
+        Assert.assertEquals(Response.Status.BAD_REQUEST, error1.getHttpStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testBaseDataRouterException(){\r
+        BaseDataRouterException exp1 = new BaseDataRouterException("id-1");\r
+        Assert.assertEquals(exp1.getId(), "id-1");\r
+\r
+        BaseDataRouterException exp2 = new BaseDataRouterException("id-1", "test-error");\r
+        Assert.assertEquals(exp2.getId(), "id-1");\r
+\r
+        BaseDataRouterException exp3 = new BaseDataRouterException("id-1", "test-error", new Throwable());\r
+        Assert.assertEquals(exp3.getId(), "id-1");\r
+    }\r
+}\r