Coverage in lock-manager 41/78041/2
authorJoss Armstrong <joss.armstrong@ericsson.com>
Thu, 7 Feb 2019 10:33:35 +0000 (10:33 +0000)
committerTakamune Cho <takamune.cho@att.com>
Thu, 7 Feb 2019 18:35:37 +0000 (18:35 +0000)
Increased package coverage to 93%

Issue-ID: APPC-1400
Change-Id: I4ff2a02466fc7a178c4d411ca4647b1c3877b405
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java [new file with mode: 0644]
appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java [new file with mode: 0644]

diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java
new file mode 100644 (file)
index 0000000..919a13c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ============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.lockmanager.impl.sql;
+
+import java.sql.Connection;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.appc.dao.util.api.JdbcConnectionFactory;
+import org.onap.appc.lockmanager.impl.sql.optimistic.MySqlLockManager;
+
+public class JdbcLockManagerTest {
+
+    @Test
+    public void testOpenDbConnection() {
+        JdbcLockManager manager = new MySqlLockManager();
+        JdbcConnectionFactory connectionFactory = Mockito.mock(JdbcConnectionFactory.class);
+        manager.setConnectionFactory(connectionFactory);
+        manager.openDbConnection();
+        Mockito.verify(connectionFactory).openDbConnection();
+    }
+
+    @Test
+    public void testCloseDbConnection() {
+        JdbcLockManager manager = new MySqlLockManager();
+        JdbcConnectionFactory connectionFactory = Mockito.mock(JdbcConnectionFactory.class);
+        manager.setConnectionFactory(connectionFactory);
+        Connection connection = Mockito.mock(Connection.class);
+        manager.closeDbConnection(connection);
+        Mockito.verify(connectionFactory).closeDbConnection(connection);
+    }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java
new file mode 100644 (file)
index 0000000..cf96a57
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * ============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.lockmanager.impl.sql;
+
+import java.sql.SQLException;
+import java.sql.DriverManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(DriverManager.class)
+public class MySqlConnectionFactoryTest {
+
+    @Test
+    public void testRegisterDriver() throws SQLException {
+        PowerMockito.mockStatic(DriverManager.class);
+        MySqlConnectionFactory factory = new MySqlConnectionFactory();
+        factory.registedDriver();
+        PowerMockito.verifyStatic();
+    }
+
+}