Test coverage in RequestValidator 14/79714/2
authorJoss Armstrong <joss.armstrong@ericsson.com>
Tue, 5 Mar 2019 14:55:41 +0000 (14:55 +0000)
committerTakamune Cho <takamune.cho@att.com>
Thu, 7 Mar 2019 00:32:44 +0000 (00:32 +0000)
Increased coverage from 61% to 79%

Issue-ID: APPC-1436
Change-Id: I4a372d40b5593f32685b09c5240654dab0aee968
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java [new file with mode: 0644]

diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java
new file mode 100644 (file)
index 0000000..c0ced1f
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.design.dbervices;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
+import org.onap.appc.design.services.util.DesignServiceConstants;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+
+public class RequestValidatorTest {
+
+
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
+    @Test
+    public void testValidateArtifactWithVersion() throws RequestValidationException, IOException {
+        RequestValidator.validate(DesignServiceConstants.GETAPPCTIMESTAMPUTC, "{}");
+        expectedEx.expect(RequestValidationException.class);
+        expectedEx.expectMessage("Missing input parameter :-artifact-contents -:");
+        RequestValidator.validate(DesignServiceConstants.UPLOADADMINARTIFACT, "{\"" +
+                DesignServiceConstants.ARTIFACT_NAME + "\":\"reference\", \"" +
+                DesignServiceConstants.ARTIFACT_VERSOIN + "\":\"VERSION\"}");
+    }
+
+    @Test
+    public void testValidateArtifact() throws RequestValidationException, IOException {
+        RequestValidator.validate(DesignServiceConstants.GETAPPCTIMESTAMPUTC, "{}");
+        expectedEx.expect(RequestValidationException.class);
+        expectedEx.expectMessage("Missing input parameter :-artifact-version -:");
+        RequestValidator.validate(DesignServiceConstants.UPLOADADMINARTIFACT, "{\"" +
+                DesignServiceConstants.ARTIFACT_NAME + "\":\"reference\"}");
+    }
+
+    @Test
+    public void testValidateVnf() throws RequestValidationException, IOException {
+        expectedEx.expect(RequestValidationException.class);
+        expectedEx.expectMessage("Missing input parameter :-vnf-type -:");
+        RequestValidator.validate(DesignServiceConstants.CHECKVNF, "{}");
+    }
+
+    @Test
+    public void testValidateInvalidAction() throws RequestValidationException, IOException {
+        expectedEx.expect(RequestValidationException.class);
+        expectedEx.expectMessage(" Action INVALID_ACTION not found while processing request ");
+        RequestValidator.validate("INVALID_ACTION", "{}");
+    }
+}