summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java6
-rw-r--r--appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionToolTest.java75
2 files changed, 79 insertions, 2 deletions
diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java
index e29920ec6..1be6967e0 100644
--- a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java
+++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications 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.
@@ -49,8 +51,8 @@ public class WrapperEncryptionTool {
String action = args[4];
String port = args[5];
String url = args[6];
- log.info("vnfType = " + vnfType + " protocol = " + protocol + " user=" + user + " password=" + password
- + " action=" + action + " port=" + port + " url=" + url);
+ log.info("vnfType = " + vnfType + " protocol = " + protocol + " " + USER_PARAM + "=" + user + " " + PASS_PARAM
+ + "=" + password + " action=" + action + " " + PORT_PARAM + "=" + port + " " + URL_PARAM + "=" + url);
if (StringUtils.isBlank(user)) {
log.info("ERROR-USER can not be null");
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();
+ }
+}