Fixing test failures

revert-70aa11f8
Ace 5 years ago
parent 91746c4d04
commit 48a0801faf

@ -213,8 +213,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
try { try {
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(), if(deviceGroup != null && deviceGroup.getGroupId() > 0) {
CarbonContext.getThreadLocalCarbonContext().getTenantId())); deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(),
CarbonContext.getThreadLocalCarbonContext().getTenantId()));
}
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
String msg = "Error occurred while obtaining group '" + groupId + "'"; String msg = "Error occurred while obtaining group '" + groupId + "'";
log.error(msg, e); log.error(msg, e);
@ -250,8 +252,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
try { try {
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(), if(deviceGroup != null && deviceGroup.getGroupId() > 0) {
CarbonContext.getThreadLocalCarbonContext().getTenantId())); deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(),
CarbonContext.getThreadLocalCarbonContext().getTenantId()));
}
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
String msg = "Error occurred while obtaining group with name: '" + groupName + "'"; String msg = "Error occurred while obtaining group with name: '" + groupName + "'";
log.error(msg, e); log.error(msg, e);
@ -280,8 +284,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroups = this.groupDAO.getGroups(tenantId); deviceGroups = this.groupDAO.getGroups(tenantId);
for(DeviceGroup group : deviceGroups){ if(deviceGroups != null && !deviceGroups.isEmpty()) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId)); for (DeviceGroup group : deviceGroups) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
}
} }
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
@ -317,8 +323,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroups = this.groupDAO.getGroups(request, tenantId); deviceGroups = this.groupDAO.getGroups(request, tenantId);
for(DeviceGroup group : deviceGroups){ if(deviceGroups != null && !deviceGroups.isEmpty()) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId)); for (DeviceGroup group : deviceGroups) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
}
} }
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
@ -365,7 +373,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
deviceGroups = this.groupDAO.getGroups(roleList, tenantId); deviceGroups = this.groupDAO.getGroups(roleList, tenantId);
for (DeviceGroup deviceGroup : deviceGroups) { for (DeviceGroup deviceGroup : deviceGroups) {
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(), tenantId)); if(deviceGroup != null && deviceGroup.getGroupId() > 0) {
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(), tenantId));
}
groups.put(deviceGroup.getGroupId(), deviceGroup); groups.put(deviceGroup.getGroupId(), deviceGroup);
} }
} catch (UserStoreException | SQLException | GroupManagementDAOException e) { } catch (UserStoreException | SQLException | GroupManagementDAOException e) {
@ -428,8 +438,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId);
for(DeviceGroup group : allMatchingGroups){ if(allMatchingGroups != null && !allMatchingGroups.isEmpty()) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId)); for (DeviceGroup group : allMatchingGroups) {
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
}
} }
} catch (GroupManagementDAOException | SQLException e) { } catch (GroupManagementDAOException | SQLException e) {
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";

@ -55,6 +55,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES (
PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME)
); );
CREATE TABLE IF NOT EXISTS GROUP_PROPERTIES (
GROUP_ID INTEGER NOT NULL,
PROPERTY_NAME VARCHAR(100) DEFAULT 0,
PROPERTY_VALUE VARCHAR(100) DEFAULT NULL,
TENANT_ID VARCHAR(100),
PRIMARY KEY (GROUP_ID, PROPERTY_NAME, TENANT_ID)
);
DROP TABLE IF EXISTS DM_DEVICE_GROUP_MAP; DROP TABLE IF EXISTS DM_DEVICE_GROUP_MAP;
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP (
ID INTEGER AUTO_INCREMENT NOT NULL, ID INTEGER AUTO_INCREMENT NOT NULL,

Loading…
Cancel
Save