Removed print stacktrace and changed the check for exceptions.

4.x.x
Menaka Jayawardena 7 years ago
parent aee8995ff6
commit ae9c1a2c8b

@ -34,6 +34,7 @@ import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.search.mgt.InvalidOperatorException;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.ProcessorImpl; import org.wso2.carbon.device.mgt.core.search.mgt.impl.ProcessorImpl;
import org.wso2.carbon.device.mgt.core.search.util.ChangeEnumValues; import org.wso2.carbon.device.mgt.core.search.util.ChangeEnumValues;
@ -116,7 +117,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest{
@Test(description = "Test for invalid state") @Test(description = "Test for invalid state")
public void testInvalidState() { public void testInvalidState() throws SearchMgtException {
SearchContext context = new SearchContext(); SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>(); List<Condition> conditions = new ArrayList<>();
@ -151,9 +152,9 @@ public class ProcessorImplTest extends BaseDeviceManagementTest{
try { try {
processor.execute(context); processor.execute(context);
} catch (SearchMgtException e) { } catch (SearchMgtException e) {
Boolean isInvalidOperation = e.getCause().getClass().getCanonicalName().contains if (!(e.getCause() instanceof InvalidOperatorException)) {
("InvalidOperatorException"); throw e;
Assert.assertTrue(isInvalidOperation); }
} }
} }

@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.search.mgt.InvalidOperatorException;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl; import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
@ -204,7 +205,7 @@ public class SearchManagementServiceTest extends BaseDeviceManagementTest {
} }
@Test(description = "Test for invalid number") @Test(description = "Test for invalid number")
public void testInvalidNumber() { public void testInvalidNumber() throws SearchMgtException {
SearchContext context = new SearchContext(); SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>(); List<Condition> conditions = new ArrayList<>();
@ -221,8 +222,9 @@ public class SearchManagementServiceTest extends BaseDeviceManagementTest {
try { try {
service.search(context); service.search(context);
} catch (SearchMgtException e) { } catch (SearchMgtException e) {
String expectedException = e.getCause().getClass().getName(); if (!(e.getCause() instanceof InvalidOperatorException)) {
Assert.assertTrue(expectedException.contains("InvalidOperatorException")); throw e;
}
} }
} }

@ -125,7 +125,6 @@ public class ChangeEnumValues {
cleanEnumCache(enumType); cleanEnumCache(enumType);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} }
} }

Loading…
Cancel
Save