|
|
@ -25,6 +25,7 @@ import org.testng.annotations.BeforeClass;
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
|
|
|
|
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.IllegalTransactionStateException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
|
|
|
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
|
|
|
|
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
|
|
|
@ -54,20 +55,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
groupId = groupDAO.addGroup(deviceGroup, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
groupId = groupDAO.addGroup(deviceGroup, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
log.debug("Group added to database. ID: " + groupId);
|
|
|
|
log.debug("Group added to database. ID: " + groupId);
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while adding device type '" + deviceGroup.getName() + "'.";
|
|
|
|
String msg = "Error occurred while adding device type '" + deviceGroup.getName() + "'.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeviceGroup group = getGroupById(groupId);
|
|
|
|
DeviceGroup group = getGroupById(groupId);
|
|
|
|
Assert.assertNotNull(group, "Group is null");
|
|
|
|
Assert.assertNotNull(group, "Group is null");
|
|
|
|
log.debug("Group name: " + group.getName());
|
|
|
|
log.debug("Group name: " + group.getName());
|
|
|
@ -81,19 +82,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
request.setGroupName(null);
|
|
|
|
request.setGroupName(null);
|
|
|
|
request.setOwner(null);
|
|
|
|
request.setOwner(null);
|
|
|
|
List<DeviceGroup> groups = groupDAO.getGroups(request, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<DeviceGroup> groups = groupDAO.getGroups(request, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
Assert.assertNotEquals(groups.size(), 0, "No groups found");
|
|
|
|
Assert.assertNotEquals(groups.size(), 0, "No groups found");
|
|
|
|
Assert.assertNotNull(groups.get(0), "Group is null");
|
|
|
|
Assert.assertNotNull(groups.get(0), "Group is null");
|
|
|
|
log.debug("No of Groups found: " + groups.size());
|
|
|
|
log.debug("No of Groups found: " + groups.size());
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -109,18 +111,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
Assert.assertEquals(roles, addedRoles, "Added roles are not equal to returned roles.");
|
|
|
|
Assert.assertEquals(roles, addedRoles, "Added roles are not equal to returned roles.");
|
|
|
|
log.debug("Group shared with roles.");
|
|
|
|
log.debug("Group shared with roles.");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -131,19 +134,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
roles.remove(0);
|
|
|
|
roles.remove(0);
|
|
|
|
List<DeviceGroup> deviceGroups = groupDAO.getGroups(roles.toArray(new String[roles.size()]), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<DeviceGroup> deviceGroups = groupDAO.getGroups(roles.toArray(new String[roles.size()]), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
Assert.assertEquals(deviceGroups.size(), 1, "Unexpected number of device groups found with role.");
|
|
|
|
Assert.assertEquals(deviceGroups.size(), 1, "Unexpected number of device groups found with role.");
|
|
|
|
Assert.assertEquals(deviceGroups.get(0).getGroupId(), groupId, "Unexpected groupId found with role.");
|
|
|
|
Assert.assertEquals(deviceGroups.get(0).getGroupId(), groupId, "Unexpected groupId found with role.");
|
|
|
|
log.debug("Group found for given roles.");
|
|
|
|
log.debug("Group found for given roles.");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while getting groups shared with roles.";
|
|
|
|
String msg = "Error occurred while getting groups shared with roles.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -157,18 +161,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<String> roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
Assert.assertNotEquals(roles, rolesToRemove, "Roles not removed.");
|
|
|
|
Assert.assertNotEquals(roles, rolesToRemove, "Roles not removed.");
|
|
|
|
log.debug("Group unshared with given roles.");
|
|
|
|
log.debug("Group unshared with given roles.");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
String msg = "Error occurred while find group by name.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -181,36 +186,38 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
groupDAO.addDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
groupDAO.addDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
log.debug("Device added to group.");
|
|
|
|
log.debug("Device added to group.");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while adding device '" + initialTestDevice.getName() + "'.";
|
|
|
|
String msg = "Error occurred while adding device '" + initialTestDevice.getName() + "'.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
List<Device> groupedDevices = groupDAO.getDevices(deviceGroup.getGroupId(), 0, 10, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
List<Device> groupedDevices = groupDAO.getDevices(deviceGroup.getGroupId(), 0, 10, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
Assert.assertNotEquals(groupedDevices.size(), 0, "No device found");
|
|
|
|
Assert.assertNotEquals(groupedDevices.size(), 0, "No device found");
|
|
|
|
Assert.assertNotNull(groupedDevices.get(0), "Device is null");
|
|
|
|
Assert.assertNotNull(groupedDevices.get(0), "Device is null");
|
|
|
|
Assert.assertEquals(groupedDevices.get(0).getId(), initialTestDevice.getId(), "Device ids not matched");
|
|
|
|
Assert.assertEquals(groupedDevices.get(0).getId(), initialTestDevice.getId(), "Device ids not matched");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while retrieving group details.";
|
|
|
|
String msg = "Error occurred while retrieving group details.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -223,18 +230,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
groupDAO.removeDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
groupDAO.removeDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
log.debug("Device added to group.");
|
|
|
|
log.debug("Device added to group.");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while adding device '" + initialTestDevice.getDeviceIdentifier() + "'.";
|
|
|
|
String msg = "Error occurred while adding device '" + initialTestDevice.getDeviceIdentifier() + "'.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -250,18 +258,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
groupDAO.updateGroup(group, groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
groupDAO.updateGroup(group, groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
log.debug("Group updated");
|
|
|
|
log.debug("Group updated");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while updating group details.";
|
|
|
|
String msg = "Error occurred while updating group details.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
group = getGroupById(groupId);
|
|
|
|
group = getGroupById(groupId);
|
|
|
@ -278,18 +287,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
groupDAO.deleteGroup(group.getGroupId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
groupDAO.deleteGroup(group.getGroupId(), TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
log.debug("Group deleted");
|
|
|
|
log.debug("Group deleted");
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
GroupManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while updating group details.";
|
|
|
|
String msg = "Error occurred while updating group details.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
String msg = "Error occurred while initiating transaction.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
group = getGroupById(groupId);
|
|
|
|
group = getGroupById(groupId);
|
|
|
|
Assert.assertNull(group, "Group is not deleted");
|
|
|
|
Assert.assertNull(group, "Group is not deleted");
|
|
|
@ -298,17 +308,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
|
|
|
|
private DeviceGroup getGroupById(int groupId) {
|
|
|
|
private DeviceGroup getGroupById(int groupId) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
return groupDAO.getGroup(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
DeviceGroup deviceGroup = groupDAO.getGroup(groupId, TestDataHolder.SUPER_TENANT_ID);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
return deviceGroup;
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while retrieving group details.";
|
|
|
|
String msg = "Error occurred while retrieving group details.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
String msg = "Error occurred while opening a connection to the data source.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
Assert.fail(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|