Changed mobile-device database schema & DAO layer

revert-dabc3590
harshanL 10 years ago
parent bbd6ff8343
commit 3d75d58782

@ -53,21 +53,27 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name> <Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.mobile.device.mgt.version}</Bundle-Version> <Bundle-Version>${carbon.mobile.device.mgt.version}</Bundle-Version>
<Bundle-Description>Device Management Mobile Impl Bundle <Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description>
</Bundle-Description> <Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package>
<!--<Bundle-Activator>org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator</Bundle-Activator>-->
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal
</Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml.bind.*,
javax.naming,
javax.sql,
javax.xml.bind.annotation,
javax.xml.parsers,
org.w3c.dom,
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.apimgt.*;
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal, !org.wso2.carbon.device.mgt.mobile.internal,
org.wso2.carbon.device.mgt.mobile.* org.wso2.carbon.device.mgt.mobile.*,
</Export-Package> </Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>

@ -53,15 +53,16 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE" +
" WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId); stmt.setString(1, mblDeviceId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileDevice = new MobileDevice(); mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(1)); mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2)); mobileDevice.setPushToken(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3)); mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4)); mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setOsVersion(resultSet.getString(5));
@ -69,6 +70,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
mobileDevice.setVendor(resultSet.getString(7)); mobileDevice.setVendor(resultSet.getString(7));
mobileDevice.setLatitude(resultSet.getString(8)); mobileDevice.setLatitude(resultSet.getString(8));
mobileDevice.setLongitude(resultSet.getString(9)); mobileDevice.setLongitude(resultSet.getString(9));
mobileDevice.setChallenge(resultSet.getString(10));
mobileDevice.setSerial(resultSet.getString(11));
mobileDevice.setToken(resultSet.getString(12));
mobileDevice.setUnlockToken(resultSet.getString(13));
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Mobile device " + mblDeviceId + " data has fetched from MDM database."); log.debug("Mobile device " + mblDeviceId + " data has fetched from MDM database.");
} }
@ -93,12 +98,13 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String createDBQuery = String createDBQuery =
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," + "INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," +
"DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; "DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, " +
"UNLOCK_TOKEN) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileDevice.getMobileDeviceId()); stmt.setString(1, mobileDevice.getMobileDeviceId());
stmt.setString(2, mobileDevice.getRegId()); stmt.setString(2, mobileDevice.getPushToken());
stmt.setString(3, mobileDevice.getImei()); stmt.setString(3, mobileDevice.getImei());
stmt.setString(4, mobileDevice.getImsi()); stmt.setString(4, mobileDevice.getImsi());
stmt.setString(5, mobileDevice.getOsVersion()); stmt.setString(5, mobileDevice.getOsVersion());
@ -106,6 +112,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
stmt.setString(7, mobileDevice.getVendor()); stmt.setString(7, mobileDevice.getVendor());
stmt.setString(8, mobileDevice.getLatitude()); stmt.setString(8, mobileDevice.getLatitude());
stmt.setString(9, mobileDevice.getLongitude()); stmt.setString(9, mobileDevice.getLongitude());
stmt.setString(10, mobileDevice.getChallenge());
stmt.setString(11, mobileDevice.getSerial());
stmt.setString(12, mobileDevice.getToken());
stmt.setString(13, mobileDevice.getUnlockToken());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
@ -134,11 +144,11 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," + "UPDATE MBL_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
"DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ? " + "DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ?, CHALLENGE = ?," +
"WHERE MOBILE_DEVICE_ID = ?"; "SERIAL = ?, TOKEN = ?, UNLOCK_TOKEN = ? WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileDevice.getRegId()); stmt.setString(1, mobileDevice.getPushToken());
stmt.setString(2, mobileDevice.getImei()); stmt.setString(2, mobileDevice.getImei());
stmt.setString(3, mobileDevice.getImsi()); stmt.setString(3, mobileDevice.getImsi());
stmt.setString(4, mobileDevice.getOsVersion()); stmt.setString(4, mobileDevice.getOsVersion());
@ -146,7 +156,11 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
stmt.setString(6, mobileDevice.getVendor()); stmt.setString(6, mobileDevice.getVendor());
stmt.setString(7, mobileDevice.getLatitude()); stmt.setString(7, mobileDevice.getLatitude());
stmt.setString(8, mobileDevice.getLongitude()); stmt.setString(8, mobileDevice.getLongitude());
stmt.setString(9, mobileDevice.getMobileDeviceId()); stmt.setString(9, mobileDevice.getChallenge());
stmt.setString(10, mobileDevice.getSerial());
stmt.setString(11, mobileDevice.getToken());
stmt.setString(12, mobileDevice.getUnlockToken());
stmt.setString(13, mobileDevice.getMobileDeviceId());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
@ -204,14 +218,14 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," +
"LATITUDE, LONGITUDE FROM MBL_DEVICE"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileDevice = new MobileDevice(); mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(1)); mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2)); mobileDevice.setPushToken(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3)); mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4)); mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setOsVersion(resultSet.getString(5));
@ -219,6 +233,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
mobileDevice.setVendor(resultSet.getString(7)); mobileDevice.setVendor(resultSet.getString(7));
mobileDevice.setLatitude(resultSet.getString(8)); mobileDevice.setLatitude(resultSet.getString(8));
mobileDevice.setLongitude(resultSet.getString(9)); mobileDevice.setLongitude(resultSet.getString(9));
mobileDevice.setChallenge(resultSet.getString(10));
mobileDevice.setSerial(resultSet.getString(11));
mobileDevice.setToken(resultSet.getString(12));
mobileDevice.setUnlockToken(resultSet.getString(13));
mobileDevices.add(mobileDevice); mobileDevices.add(mobileDevice);
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -26,7 +26,7 @@ import java.io.Serializable;
public class MobileDevice implements Serializable { public class MobileDevice implements Serializable {
private String mobileDeviceId; private String mobileDeviceId;
private String regId; private String pushToken;
private String imei; private String imei;
private String imsi; private String imsi;
private String osVersion; private String osVersion;
@ -34,6 +34,42 @@ public class MobileDevice implements Serializable {
private String vendor; private String vendor;
private String latitude; private String latitude;
private String longitude; private String longitude;
private String serial;
private String unlockToken;
private String token;
private String challenge;
public String getUnlockToken() {
return unlockToken;
}
public void setUnlockToken(String unlockToken) {
this.unlockToken = unlockToken;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getChallenge() {
return challenge;
}
public void setChallenge(String challenge) {
this.challenge = challenge;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public String getMobileDeviceId() { public String getMobileDeviceId() {
return mobileDeviceId; return mobileDeviceId;
@ -43,12 +79,12 @@ public class MobileDevice implements Serializable {
this.mobileDeviceId = mobileDeviceId; this.mobileDeviceId = mobileDeviceId;
} }
public String getRegId() { public String getPushToken() {
return regId; return pushToken;
} }
public void setRegId(String regId) { public void setPushToken(String pushToken) {
this.regId = regId; this.pushToken = pushToken;
} }
public String getImei() { public String getImei() {

@ -42,12 +42,16 @@ public class MobileDeviceManagementUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class); private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
private static final String MOBILE_DEVICE_IMEI = "imei"; private static final String MOBILE_DEVICE_IMEI = "imei";
private static final String MOBILE_DEVICE_IMSI = "imsi"; private static final String MOBILE_DEVICE_IMSI = "imsi";
private static final String MOBILE_DEVICE_REG_ID = "regId"; private static final String MOBILE_DEVICE_PUSH_TOKEN = "pushToken";
private static final String MOBILE_DEVICE_VENDOR = "vendor"; private static final String MOBILE_DEVICE_VENDOR = "vendor";
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion"; private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
private static final String MOBILE_DEVICE_MODEL = "model"; private static final String MOBILE_DEVICE_MODEL = "model";
private static final String MOBILE_DEVICE_LATITUDE = "latitude"; private static final String MOBILE_DEVICE_LATITUDE = "latitude";
private static final String MOBILE_DEVICE_LONGITUDE = "longitude"; private static final String MOBILE_DEVICE_LONGITUDE = "longitude";
private static final String MOBILE_DEVICE_TOKEN = "token";
private static final String MOBILE_DEVICE_SERIAL = "serial";
private static final String MOBILE_DEVICE_UNLOCK_TOKEN = "unlockToken";
private static final String MOBILE_DEVICE_CHALLENGE = "challenge";
public static Document convertToDocument(File file) throws DeviceManagementException { public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@ -87,12 +91,16 @@ public class MobileDeviceManagementUtil {
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier()); mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI)); mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI)); mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID)); mobileDevice.setPushToken(getPropertyValue(device, MOBILE_DEVICE_PUSH_TOKEN));
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
mobileDevice.setChallenge(getPropertyValue(device, MOBILE_DEVICE_CHALLENGE));
mobileDevice.setToken(getPropertyValue(device, MOBILE_DEVICE_TOKEN));
mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL));
mobileDevice.setUnlockToken(getPropertyValue(device, MOBILE_DEVICE_UNLOCK_TOKEN));
} }
return mobileDevice; return mobileDevice;
} }
@ -104,12 +112,16 @@ public class MobileDeviceManagementUtil {
List<Device.Property> propertyList = new ArrayList<Device.Property>(); List<Device.Property> propertyList = new ArrayList<Device.Property>();
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei())); propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi())); propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId())); propertyList.add(getProperty(MOBILE_DEVICE_PUSH_TOKEN, mobileDevice.getPushToken()));
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel())); propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
propertyList.add(getProperty(MOBILE_DEVICE_CHALLENGE, mobileDevice.getChallenge()));
propertyList.add(getProperty(MOBILE_DEVICE_TOKEN, mobileDevice.getToken()));
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
propertyList.add(getProperty(MOBILE_DEVICE_UNLOCK_TOKEN, mobileDevice.getUnlockToken()));
device.setProperties(propertyList); device.setProperties(propertyList);
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
} }

@ -51,10 +51,14 @@ public class MobileDeviceDAOTestSuite {
public static final String TEST_MOBILE_MODEL = "S5"; public static final String TEST_MOBILE_MODEL = "S5";
public static final String TEST_MOBILE_VENDOR = "samsung"; public static final String TEST_MOBILE_VENDOR = "samsung";
public static final String TEST_MOBILE_UPDATED_VENDOR = "sony"; public static final String TEST_MOBILE_UPDATED_VENDOR = "sony";
public static final String TEST_MOBILE_REG_ID = "2414"; public static final String TEST_MOBILE_PUSH_TOKEN = "2414";
public static final String TEST_MOBILE_OS_VERSION = "5.0.0"; public static final String TEST_MOBILE_OS_VERSION = "5.0.0";
public static final String TEST_MOBILE_LATITUDE = "6.93N"; public static final String TEST_MOBILE_LATITUDE = "6.93N";
public static final String TEST_MOBILE_LONGITUDE = "80.60E"; public static final String TEST_MOBILE_LONGITUDE = "80.60E";
public static final String TEST_MOBILE_TOKEN = "2412K2HKHK24K12H4";
public static final String TEST_MOBILE_SERIAL = "24124IIH4I2K4";
public static final String TEST_MOBILE_CHALLENGE = "ASFASFSAFASFATWTWQTTQWTWQTQWTQWTWQT";
public static final String TEST_MOBILE_UNLOCK_TOKEN = "FAFWQUWFUQWYWQYRWQURYUURUWQUWRUWRUWE";
private TestDBConfiguration testDBConfiguration; private TestDBConfiguration testDBConfiguration;
private MobileDeviceDAOImpl mblDeviceDAO; private MobileDeviceDAOImpl mblDeviceDAO;
@ -93,23 +97,28 @@ public class MobileDeviceDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_VENDOR); mobileDevice.setVendor(TEST_MOBILE_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_PUSH_TOKEN);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
boolean added = mblDeviceDAO.addMobileDevice(mobileDevice); boolean added = mblDeviceDAO.addMobileDevice(mobileDevice);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
testMblDevice.setMobileDeviceId(resultSet.getString(1)); testMblDevice.setMobileDeviceId(resultSet.getString(1));
testMblDevice.setRegId(resultSet.getString(2)); testMblDevice.setPushToken(resultSet.getString(2));
testMblDevice.setImei(resultSet.getString(3)); testMblDevice.setImei(resultSet.getString(3));
testMblDevice.setImsi(resultSet.getString(4)); testMblDevice.setImsi(resultSet.getString(4));
testMblDevice.setOsVersion(resultSet.getString(5)); testMblDevice.setOsVersion(resultSet.getString(5));
@ -117,6 +126,10 @@ public class MobileDeviceDAOTestSuite {
testMblDevice.setVendor(resultSet.getString(7)); testMblDevice.setVendor(resultSet.getString(7));
testMblDevice.setLatitude(resultSet.getString(8)); testMblDevice.setLatitude(resultSet.getString(8));
testMblDevice.setLongitude(resultSet.getString(9)); testMblDevice.setLongitude(resultSet.getString(9));
testMblDevice.setChallenge(resultSet.getString(10));
testMblDevice.setSerial(resultSet.getString(11));
testMblDevice.setToken(resultSet.getString(12));
testMblDevice.setUnlockToken(resultSet.getString(13));
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error in retrieving Mobile Device data "; String msg = "Error in retrieving Mobile Device data ";
@ -140,10 +153,18 @@ public class MobileDeviceDAOTestSuite {
"MobileDevice model has persisted "); "MobileDevice model has persisted ");
Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(), Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(),
"MobileDevice os-version has persisted "); "MobileDevice os-version has persisted ");
Assert.assertEquals(TEST_MOBILE_REG_ID, testMblDevice.getRegId(), Assert.assertEquals(TEST_MOBILE_PUSH_TOKEN, testMblDevice.getPushToken(),
"MobileDevice reg-id has persisted "); "MobileDevice reg-id has persisted ");
Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(), Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(),
"MobileDevice vendor has persisted "); "MobileDevice vendor has persisted ");
Assert.assertEquals(TEST_MOBILE_CHALLENGE, testMblDevice.getChallenge(),
"MobileDevice challenge has persisted ");
Assert.assertEquals(TEST_MOBILE_SERIAL, testMblDevice.getSerial(),
"MobileDevice serial has persisted");
Assert.assertEquals(TEST_MOBILE_UNLOCK_TOKEN, testMblDevice.getUnlockToken(),
"MobileDevice unlock-token has persisted");
Assert.assertEquals(TEST_MOBILE_TOKEN, testMblDevice.getToken(),
"MobileDevice token has persisted");
} }
@Test(dependsOnMethods = { "addMobileDeviceTest" }) @Test(dependsOnMethods = { "addMobileDeviceTest" })
@ -164,10 +185,18 @@ public class MobileDeviceDAOTestSuite {
"MobileDevice model has persisted "); "MobileDevice model has persisted ");
Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(), Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(),
"MobileDevice os-version has persisted "); "MobileDevice os-version has persisted ");
Assert.assertEquals(TEST_MOBILE_REG_ID, testMblDevice.getRegId(), Assert.assertEquals(TEST_MOBILE_PUSH_TOKEN, testMblDevice.getPushToken(),
"MobileDevice reg-id has persisted "); "MobileDevice reg-id has persisted ");
Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(), Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(),
"MobileDevice vendor has persisted "); "MobileDevice vendor has persisted ");
Assert.assertEquals(TEST_MOBILE_CHALLENGE, testMblDevice.getChallenge(),
"MobileDevice challenge has persisted ");
Assert.assertEquals(TEST_MOBILE_SERIAL, testMblDevice.getSerial(),
"MobileDevice serial has persisted");
Assert.assertEquals(TEST_MOBILE_UNLOCK_TOKEN, testMblDevice.getUnlockToken(),
"MobileDevice unlock-token has persisted");
Assert.assertEquals(TEST_MOBILE_TOKEN, testMblDevice.getToken(),
"MobileDevice token has persisted");
} }
@Test(dependsOnMethods = { "addMobileDeviceTest" }) @Test(dependsOnMethods = { "addMobileDeviceTest" })
@ -192,23 +221,28 @@ public class MobileDeviceDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_UPDATED_VENDOR); mobileDevice.setVendor(TEST_MOBILE_UPDATED_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_PUSH_TOKEN);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
boolean updated = mblDeviceDAO.updateMobileDevice(mobileDevice); boolean updated = mblDeviceDAO.updateMobileDevice(mobileDevice);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
testMblDevice.setMobileDeviceId(resultSet.getString(1)); testMblDevice.setMobileDeviceId(resultSet.getString(1));
testMblDevice.setRegId(resultSet.getString(2)); testMblDevice.setPushToken(resultSet.getString(2));
testMblDevice.setImei(resultSet.getString(3)); testMblDevice.setImei(resultSet.getString(3));
testMblDevice.setImsi(resultSet.getString(4)); testMblDevice.setImsi(resultSet.getString(4));
testMblDevice.setOsVersion(resultSet.getString(5)); testMblDevice.setOsVersion(resultSet.getString(5));
@ -216,6 +250,10 @@ public class MobileDeviceDAOTestSuite {
testMblDevice.setVendor(resultSet.getString(7)); testMblDevice.setVendor(resultSet.getString(7));
testMblDevice.setLatitude(resultSet.getString(8)); testMblDevice.setLatitude(resultSet.getString(8));
testMblDevice.setLongitude(resultSet.getString(9)); testMblDevice.setLongitude(resultSet.getString(9));
testMblDevice.setChallenge(resultSet.getString(10));
testMblDevice.setSerial(resultSet.getString(11));
testMblDevice.setToken(resultSet.getString(12));
testMblDevice.setUnlockToken(resultSet.getString(13));
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error in retrieving Mobile Device data "; String msg = "Error in retrieving Mobile Device data ";
@ -240,8 +278,9 @@ public class MobileDeviceDAOTestSuite {
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();

@ -59,6 +59,10 @@ public class MobileDeviceOperationMappingDAOTestSuite {
public static final String TEST_MOBILE_OS_VERSION = "5.0.0"; public static final String TEST_MOBILE_OS_VERSION = "5.0.0";
public static final String TEST_MOBILE_LATITUDE = "6.93N"; public static final String TEST_MOBILE_LATITUDE = "6.93N";
public static final String TEST_MOBILE_LONGITUDE = "80.60E"; public static final String TEST_MOBILE_LONGITUDE = "80.60E";
public static final String TEST_MOBILE_TOKEN = "2412K2HKHK24K12H4";
public static final String TEST_MOBILE_SERIAL = "24124IIH4I2K4";
public static final String TEST_MOBILE_CHALLENGE = "ASFASFSAFASFATWTWQTTQWTWQTQWTQWTWQT";
public static final String TEST_MOBILE_UNLOCK_TOKEN = "FAFWQUWFUQWYWQYRWQURYUURUWQUWRUWRUWE";
public static final String TEST_MBL_OPR_FEATURE_CODE1 = "LOCK"; public static final String TEST_MBL_OPR_FEATURE_CODE1 = "LOCK";
public static final String TEST_MBL_OPR_FEATURE_CODE2 = "WIPE"; public static final String TEST_MBL_OPR_FEATURE_CODE2 = "WIPE";
public static final long TEST_MBL_OPR_CREATED_DATE = new java.util.Date().getTime(); public static final long TEST_MBL_OPR_CREATED_DATE = new java.util.Date().getTime();
@ -112,10 +116,14 @@ public class MobileDeviceOperationMappingDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_VENDOR); mobileDevice.setVendor(TEST_MOBILE_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_REG_ID);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
mblDeviceDAO.addMobileDevice(mobileDevice); mblDeviceDAO.addMobileDevice(mobileDevice);
//Add an Operation to the db //Add an Operation to the db

@ -4,7 +4,7 @@
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL , `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
`REG_ID` VARCHAR(45) NULL DEFAULT NULL , `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL , `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL , `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
@ -12,6 +12,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`VENDOR` VARCHAR(45) NULL DEFAULT NULL , `VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL, `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) ); PRIMARY KEY (`MOBILE_DEVICE_ID`) );

Loading…
Cancel
Save