summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/test/java/org/onap
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-28 08:10:55 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-28 14:41:40 +0000
commit86755a65c526dfd8c8bab1235ddf273b7eb64c1f (patch)
tree4f96db502b2f20a43c6e566306ead6d43814b9df /appc-provider/appc-provider-bundle/src/test/java/org/onap
parent86dd2bc3a4e2316cd20c95f7a85a68ccd2f49894 (diff)
Test coverage in MockQueryHelper
Increased coverage from 17% to 91% Fixed Sonar major issue for branch coverage Issue-ID: APPC-1509 Change-Id: I822053c74db8f16875448206a22048032d30ad45 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/test/java/org/onap')
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/mock/query/MockQueryHelperTest.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/mock/query/MockQueryHelperTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/mock/query/MockQueryHelperTest.java
new file mode 100644
index 000000000..17bde75af
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/mock/query/MockQueryHelperTest.java
@@ -0,0 +1,61 @@
+/*
+ * ============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.provider.lcm.mock.query;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.appc.domainmodel.lcm.ActionIdentifiers;
+import org.onap.appc.domainmodel.lcm.RequestContext;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.powermock.reflect.Whitebox;
+
+public class MockQueryHelperTest {
+
+ @Test
+ public void testVnfIdFound() {
+ MockQueryHelper mockQueryHelper = new MockQueryHelper();
+ Whitebox.setInternalState(mockQueryHelper, "MOCK_QUERY_FILENAME", "./src/test/resources/query");
+ RequestHandlerInput requestHandlerInput = new RequestHandlerInput();
+ RequestContext requestContext = new RequestContext();
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ actionIdentifiers.setVnfId("vSCP");
+ requestContext.setActionIdentifiers(actionIdentifiers);
+ requestHandlerInput.setRequestContext(requestContext);
+ assertEquals(LCMCommandStatus.SUCCESS.getResponseCode(),
+ mockQueryHelper.query(requestHandlerInput).getResponseContext().getStatus().getCode());
+ }
+
+ @Test
+ public void testVnfIdNotFound() {
+ MockQueryHelper mockQueryHelper = new MockQueryHelper();
+ Whitebox.setInternalState(mockQueryHelper, "MOCK_QUERY_FILENAME", "./src/test/resources/query");
+ RequestHandlerInput requestHandlerInput = new RequestHandlerInput();
+ RequestContext requestContext = new RequestContext();
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ actionIdentifiers.setVnfId("OTHER_VNF_ID");
+ requestContext.setActionIdentifiers(actionIdentifiers);
+ requestHandlerInput.setRequestContext(requestContext);
+ assertEquals(LCMCommandStatus.VNF_NOT_FOUND.getResponseCode(),
+ mockQueryHelper.query(requestHandlerInput).getResponseContext().getStatus().getCode());
+ }
+}