summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-encryption-tool/provider/src/test
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-11 11:37:11 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-11 14:15:02 +0000
commitc99acfce1a84cb6d7f827f8585af9c01d0383b67 (patch)
tree7af486e22ae5162ae9baf79f6d87ffbac3a345dc /appc-config/appc-encryption-tool/provider/src/test
parent991d833fd7558beaf7f2f2df63deb72dabda3e8a (diff)
Test coverage in wrapperEncryptionTool
Increased coverage from 0% to 81% Issue-ID: APPC-1409 Change-Id: I1b4d285eff9fad8a60e855a97ff843078d628862 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-encryption-tool/provider/src/test')
-rw-r--r--appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionToolTest.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionToolTest.java b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionToolTest.java
new file mode 100644
index 000000000..5e68150e8
--- /dev/null
+++ b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionToolTest.java
@@ -0,0 +1,75 @@
+/*
+ * ============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.encryptiontool.wrapper;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import com.sun.rowset.CachedRowSetImpl;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(DbServiceUtil.class)
+public class WrapperEncryptionToolTest {
+
+ private DbLibService dbLibService;
+ private DBResourceManager dbResourceManager;
+
+
+ @Test
+ public void testAnsible() throws SQLException, IOException {
+ PowerMockito.mockStatic(DbServiceUtil.class);
+ dbLibService = Mockito.mock(DbLibService.class);
+ dbResourceManager = Mockito.mock(DBResourceManager.class);
+ CachedRowSetImpl rowset = Mockito.mock(CachedRowSetImpl.class);
+ Mockito.when(rowset.first()).thenReturn(true);
+ Mockito.when(rowset.getString(Mockito.anyString()))
+ .thenReturn(null);
+ PowerMockito.when(DbServiceUtil.getData(Mockito.anyString(), Mockito.anyList(), Mockito.anyString(),
+ Mockito.anyString(), Mockito.anyString())).thenReturn(rowset);
+ PowerMockito.when(DbServiceUtil.initDbLibService()).thenReturn(dbResourceManager);
+ WrapperEncryptionTool.main(new String[] {"VNF-TYPE", "ANSIBLE", "USER", "PASS", "ACTION", "PORT", "URL"});
+ Mockito.verify(dbResourceManager).cleanUp();
+ }
+
+ @Test
+ public void testNonAnsible() throws SQLException, IOException {
+ PowerMockito.mockStatic(DbServiceUtil.class);
+ dbLibService = Mockito.mock(DbLibService.class);
+ dbResourceManager = Mockito.mock(DBResourceManager.class);
+ CachedRowSetImpl rowset = Mockito.mock(CachedRowSetImpl.class);
+ Mockito.when(rowset.first()).thenReturn(true);
+ Mockito.when(rowset.getString(Mockito.anyString()))
+ .thenReturn(null);
+ PowerMockito.when(DbServiceUtil.getData(Mockito.anyString(), Mockito.anyList(), Mockito.anyString(),
+ Mockito.anyString(), Mockito.anyString())).thenReturn(rowset);
+ PowerMockito.when(DbServiceUtil.initDbLibService()).thenReturn(dbResourceManager);
+ WrapperEncryptionTool.main(new String[] {"VNF-TYPE", "TEST", "USER", "PASS", "ACTION", "PORT", "URL"});
+ Mockito.verify(dbResourceManager).cleanUp();
+ }
+}