Device DAO unit tests implementation

revert-70aa11f8
manoj 10 years ago
parent 6a86ab43c1
commit 10a05b024f

@ -73,6 +73,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>

@ -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() + "'";

@ -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;
}

@ -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;
}

@ -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;

@ -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;

@ -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,

Loading…
Cancel
Save