From 461361ba2dc75cbd36da40c9d7078e69878905e4 Mon Sep 17 00:00:00 2001 From: megala21 Date: Thu, 28 Sep 2017 21:07:21 +0530 Subject: [PATCH] Refactoring --- .../type/template/DeviceTypeManagerTest.java | 18 +++++++++--------- .../device/mgt/extensions/utils/Utils.java | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerTest.java index d896eaa73d..afdf2d560f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerTest.java @@ -90,6 +90,15 @@ public class DeviceTypeManagerTest { if (resourceUrl != null) { androidConfiguration = new File(resourceUrl.getFile()); } + datasourceField = DeviceTypeDAOHandler.class.getDeclaredField("dataSource"); + datasourceField.setAccessible(true); + currentConnection = DeviceTypeDAOHandler.class.getDeclaredField("currentConnection"); + currentConnection.setAccessible(true); + deviceTypePluginDAOField = DeviceTypePluginDAOManager.class.getDeclaredField("deviceTypePluginDAO"); + deviceTypePluginDAOField.setAccessible(true); + deviceTypeDAOHandlerField = DeviceTypePluginDAOManager.class.getDeclaredField("deviceTypeDAOHandler"); + deviceTypeDAOHandlerField.setAccessible(true); + DeviceTypeConfiguration androidDeviceConfiguration = Utils.getDeviceTypeConfiguration(androidConfiguration); androidDeviceTypeManager = Mockito.mock(DeviceTypeManager.class, Mockito.CALLS_REAL_METHODS); customDeviceTypeManager = Mockito.mock(DeviceTypeManager.class, Mockito.CALLS_REAL_METHODS); @@ -108,15 +117,6 @@ public class DeviceTypeManagerTest { Field deviceType = DeviceTypeManager.class.getDeclaredField("deviceType"); deviceType.setAccessible(true); - datasourceField = DeviceTypeDAOHandler.class.getDeclaredField("dataSource"); - datasourceField.setAccessible(true); - currentConnection = DeviceTypeDAOHandler.class.getDeclaredField("currentConnection"); - currentConnection.setAccessible(true); - deviceTypePluginDAOField = DeviceTypePluginDAOManager.class.getDeclaredField("deviceTypePluginDAO"); - deviceTypePluginDAOField.setAccessible(true); - deviceTypeDAOHandlerField = DeviceTypePluginDAOManager.class.getDeclaredField("deviceTypeDAOHandler"); - deviceTypeDAOHandlerField.setAccessible(true); - deviceType.set(androidDeviceTypeManager, androidDeviceType); propertiesExist.set(androidDeviceTypeManager, true); createAndroidDevice(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/utils/Utils.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/utils/Utils.java index 910a5986c5..0e6c37cd1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/utils/Utils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/utils/Utils.java @@ -106,7 +106,6 @@ public class Utils { dataSource.setUser("sa"); dataSource.setPassword("sa"); - File file = new File(scriptFilePath); final String LOAD_DATA_QUERY = "RUNSCRIPT FROM '" + file.getCanonicalPath() + "'";