summaryrefslogtreecommitdiffstats
path: root/appc-sequence-generator
diff options
context:
space:
mode:
authorLathishbabu Ganesan <lathishbabu.ganesan@ericsson.com>2019-02-27 09:29:34 -0500
committerTakamune Cho <takamune.cho@att.com>2019-02-27 16:57:03 +0000
commit375082572741a5c20059d10ccefb682c7cc44e54 (patch)
treedbbe1015dc790a7407c82cc552135535f525d015 /appc-sequence-generator
parentcb0bdc23c3640b1557121fde6fe8a2e4aa52a0ff (diff)
Added test cases for Sequence Generator class
Increased the code coverage from 0% to 100% Issue-ID: APPC-1457 Change-Id: Id71298cb482a1c9ca00c3ced9685087e56c249ca Signed-off-by: Lathishbabu Ganesan <lathishbabu.ganesan@ericsson.com>
Diffstat (limited to 'appc-sequence-generator')
-rw-r--r--appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/dbservices/TestSequenceGeneratorDBServices.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/dbservices/TestSequenceGeneratorDBServices.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/dbservices/TestSequenceGeneratorDBServices.java
new file mode 100644
index 000000000..3328ccde1
--- /dev/null
+++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/dbservices/TestSequenceGeneratorDBServices.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.seqgen.dbservices;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+
+public class TestSequenceGeneratorDBServices {
+
+ private SequenceGeneratorDBServices sequenceGeneratorDBServices;
+ private SvcLogicContext localContext;
+ private SvcLogicResource serviceLogic;
+
+ @Before
+ public void setUp() {
+ localContext = new SvcLogicContext();
+ localContext.setAttribute("artifact-content", "artifact");
+ sequenceGeneratorDBServices = new SequenceGeneratorDBServices();
+ serviceLogic = Mockito.mock(SvcLogicResource.class);
+ Whitebox.setInternalState(sequenceGeneratorDBServices, "serviceLogic", serviceLogic);
+ }
+
+ @Test
+ public void testGetOutputPayloadTemplate() throws SvcLogicException {
+ when(serviceLogic.query(eq("SQL"), eq(false), eq(null), anyString(), eq(null), eq(null), eq(localContext)))
+ .thenReturn(QueryStatus.SUCCESS);
+ assertEquals("artifact", sequenceGeneratorDBServices.getOutputPayloadTemplate(localContext));
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testGetOutputPayloadTemplateException() throws SvcLogicException {
+ when(serviceLogic.query(eq("SQL"), eq(false), eq(null), anyString(), eq(null), eq(null), eq(localContext)))
+ .thenReturn(QueryStatus.FAILURE);
+ sequenceGeneratorDBServices.getOutputPayloadTemplate(localContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testGetOutputPayloadTemplateFailure() throws SvcLogicException {
+ String query =
+ "select artifact_content from asdc_artifacts where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
+ when(serviceLogic.query("SQL", false, null, query, null, null, localContext)).thenReturn(QueryStatus.FAILURE);
+ sequenceGeneratorDBServices.getOutputPayloadTemplate(localContext);
+ }
+
+ @Test
+ public void testGetOutputPayloadTemplateNullContext() throws SvcLogicException {
+ assertNull(sequenceGeneratorDBServices.getOutputPayloadTemplate(null));
+ }
+
+ @Test
+ public void testInitialise() throws SvcLogicException {
+ assertNotNull(SequenceGeneratorDBServices.initialise());
+ }
+
+}