From 6c0d0f89a41bf7443371f1b6f3863565e97a6d0f Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 11 Oct 2017 18:54:47 +0530 Subject: [PATCH] Refactoring --- .../service/DeviceManagementProviderServiceImpl.java | 5 ++++- .../mgt/core/search/SearchManagementServiceTest.java | 10 +++++++--- .../src/test/resources/testng.xml | 2 -- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 5d28eb34afd..5244a74201f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -280,7 +280,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv try { deviceInformationManager.addDeviceInfo(deviceIdentifier, device.getDeviceInfo()); } catch (DeviceDetailsMgtException e) { - e.printStackTrace(); + String msg = "Error occurred while adding device info for the device " + + device.getDeviceIdentifier(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/SearchManagementServiceTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/SearchManagementServiceTest.java index aa179b967a1..242df3cecbb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/SearchManagementServiceTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/SearchManagementServiceTest.java @@ -43,12 +43,16 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; + +/** + * This class contains unit tests for the class SearchManagerService + * */ public class SearchManagementServiceTest extends BaseDeviceManagementTest { private static final Log log = LogFactory.getLog(SearchManagementServiceTest.class); private static List deviceIdentifiers = new ArrayList<>(); - private static String DEVICE_ID_PREFIX = "SEARCH-DEVICE-ID-"; - private static String DEVICE_TYPE = "SEARCH_TYPE"; + private static final String DEVICE_ID_PREFIX = "SEARCH-DEVICE-ID-"; + private static final String DEVICE_TYPE = "SEARCH_TYPE"; @BeforeClass public void init() throws Exception { @@ -133,7 +137,7 @@ public class SearchManagementServiceTest extends BaseDeviceManagementTest { Assert.assertTrue(devices.size() == 0); } - @Test + @Test(description = "Search devices by string parameter.") public void testStringSearch() throws Exception { SearchContext context = new SearchContext(); List conditions = new ArrayList<>(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index 01752512bb4..e3c165ca99f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -32,7 +32,6 @@ - @@ -50,7 +49,6 @@ -