diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
index 76a49c871..e839f5407 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
@@ -73,6 +73,11 @@
org.apache.maven.plugins
maven-surefire-plugin
2.18
+
+
+ src/test/resources/testng.xml
+
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
index 94bdc0604..a9e4df8c0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
@@ -61,10 +61,10 @@ public class DeviceDAOImpl implements DeviceDAO {
stmt.setLong(4, new Date().getTime());
stmt.setString(5, device.getOwnerShip());
stmt.setString(6, device.getStatus().toString());
- stmt.setString(7, device.getDeviceType());
+ stmt.setInt(7, device.getDeviceType());
stmt.setString(8, device.getDeviceIdentificationId());
stmt.setString(9, device.getOwnerId());
- stmt.setInt(10, DeviceManagementDAOUtil.getTenantId());
+ stmt.setInt(10, device.getTenantId());
stmt.executeUpdate();
} catch (SQLException e) {
String msg = "Error occurred while enrolling device '" + device.getName() + "'";
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
index b15f94d23..b71aaeaa1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
@@ -113,7 +113,7 @@ public final class DeviceManagementDAOUtil {
deviceBO.setOwnerId(device.getOwner());
deviceBO.setOwnerShip(device.getOwnership());
deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId());
- deviceBO.setDeviceType(device.getType());
+ deviceBO.setDeviceType(Integer.parseInt(device.getType()));
return deviceBO;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java
index 8adbd5ff7..21c951cfa 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java
@@ -33,13 +33,13 @@ public class Device implements Serializable {
private String ownerId;
private String ownerShip;
private int tenantId;
- private String deviceType;
+ private Integer deviceType;
- public String getDeviceType() {
+ public Integer getDeviceType() {
return deviceType;
}
- public void setDeviceType(String deviceType) {
+ public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java
index 3b8dd365c..9689cd262 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java
@@ -47,6 +47,7 @@ public class TestDBConfiguration {
public void setConnectionUrl(String connectionUrl) {
this.connectionUrl = connectionUrl;
}
+
@XmlElement(name = "driverclass", nillable = false)
public String getDriverClass() {
return driverClass;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java
index 1616fc6ee..116a24907 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java
@@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration;
import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
+import org.wso2.carbon.device.mgt.core.dto.OwnerShip;
import org.wso2.carbon.device.mgt.core.dto.Status;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
@@ -146,8 +147,10 @@ public class DeviceMgtDAOTestSuite {
device.setDescription("test description");
device.setStatus(Status.ACTIVE);
device.setDeviceIdentificationId("111");
- device.setDeviceType(devType.getId().toString());
+ device.setDeviceType(devType.getId().intValue());
+ device.setOwnerShip(OwnerShip.BYOD.toString());
device.setOwnerId("111");
+ device.setTenantId(-1234);
deviceMgtDAO.addDevice(device);
Long deviceId = null;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
index 0733f5552..afcd19ca0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
@@ -10,8 +10,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE
ID INT auto_increment NOT NULL,
DESCRIPTION TEXT NULL DEFAULT NULL,
NAME VARCHAR(100) NULL DEFAULT NULL,
- DATE_OF_ENROLLMENT INTEGER NULL DEFAULT NULL,
- DATE_OF_LAST_UPDATE INTEGER NULL DEFAULT NULL,
+ DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
+ DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
STATUS VARCHAR(15) NULL DEFAULT NULL,
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,