Merge pull request #986 from charithag/master

Add additional test cases for grouping
4.x.x
Geeth 7 years ago committed by GitHub
commit d29e6b65c8

@ -259,7 +259,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Get groups"); log.debug("Get groups");
} }
List<DeviceGroup> deviceGroups = new ArrayList<>(); List<DeviceGroup> deviceGroups;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
@ -293,7 +293,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
log.debug("Get groups with pagination " + request.toString()); log.debug("Get groups with pagination " + request.toString());
} }
request = DeviceManagerUtil.validateGroupListPageSize(request); request = DeviceManagerUtil.validateGroupListPageSize(request);
List<DeviceGroup> deviceGroups = new ArrayList<>(); List<DeviceGroup> deviceGroups;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
@ -345,14 +345,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
for (DeviceGroup deviceGroup : deviceGroups) { for (DeviceGroup deviceGroup : deviceGroups) {
groups.put(deviceGroup.getGroupId(), deviceGroup); groups.put(deviceGroup.getGroupId(), deviceGroup);
} }
// } catch (UserStoreException e) {
// String msg = "Error occurred while getting user store manager.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while retrieving all groups accessible to user.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (UserStoreException | SQLException | GroupManagementDAOException e) { } catch (UserStoreException | SQLException | GroupManagementDAOException e) {
String msg = "Error occurred while retrieving all groups accessible to user."; String msg = "Error occurred while retrieving all groups accessible to user.";
log.error(msg, e); log.error(msg, e);
@ -368,16 +360,11 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
private List<Integer> getGroupIds(String username) throws GroupManagementException { private List<Integer> getGroupIds(String username) throws GroupManagementException {
if (username == null || username.isEmpty()) {
String msg = "Received empty user name for getGroupIds";
log.error(msg);
throw new GroupManagementException(msg);
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Get groups Ids of owner '" + username + "'"); log.debug("Get groups Ids of owner '" + username + "'");
} }
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
List<Integer> deviceGroupIds = new ArrayList<>(); List<Integer> deviceGroupIds;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
userStoreManager = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) userStoreManager = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
@ -386,14 +373,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
deviceGroupIds = this.groupDAO.getOwnGroupIds(username, tenantId); deviceGroupIds = this.groupDAO.getOwnGroupIds(username, tenantId);
deviceGroupIds.addAll(this.groupDAO.getGroupIds(roleList, tenantId)); deviceGroupIds.addAll(this.groupDAO.getGroupIds(roleList, tenantId));
// } catch (UserStoreException e) {
// String msg = "Error occurred while getting user store manager.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while retrieving all groups accessible to user.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (UserStoreException | SQLException | GroupManagementDAOException e) { } catch (UserStoreException | SQLException | GroupManagementDAOException e) {
String msg = "Error occurred while retrieving all groups accessible to user."; String msg = "Error occurred while retrieving all groups accessible to user.";
log.error(msg, e); log.error(msg, e);
@ -421,7 +400,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} }
request = DeviceManagerUtil.validateGroupListPageSize(request); request = DeviceManagerUtil.validateGroupListPageSize(request);
List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser); List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser);
List<DeviceGroup> allMatchingGroups = new ArrayList<>(); List<DeviceGroup> allMatchingGroups;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
@ -430,10 +409,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getGroups"; String msg = "Error occurred in getGroups";
log.error(msg, e); log.error(msg, e);
@ -460,10 +435,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred"; String msg = "Error occurred";
log.error(msg, e); log.error(msg, e);
@ -490,10 +461,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getGroupCount"; String msg = "Error occurred in getGroupCount";
log.error(msg, e); log.error(msg, e);
@ -527,18 +494,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
count = groupDAO.getOwnGroupsCount(username, tenantId); count = groupDAO.getOwnGroupsCount(username, tenantId);
count += groupDAO.getGroupsCount(roleList, tenantId); count += groupDAO.getGroupsCount(roleList, tenantId);
return count; return count;
// } catch (UserStoreException e) {
// String msg = "Error occurred while getting user store manager.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (UserStoreException | GroupManagementDAOException | SQLException e) { } catch (UserStoreException | GroupManagementDAOException | SQLException e) {
String msg = "Error occurred while retrieving group count of user '" + username + "'"; String msg = "Error occurred while retrieving group count of user '" + username + "'";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getGroupCount for username '" + username + "'"; String msg = "Error occurred in getGroupCount for username '" + username + "'";
log.error(msg, e); log.error(msg, e);
@ -619,10 +578,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getRoles for groupId: " + groupId; String msg = "Error occurred in getRoles for groupId: " + groupId;
log.error(msg, e); log.error(msg, e);
@ -651,14 +606,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while getting devices in group."; String msg = "Error occurred while getting devices in group.";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
// } catch (DeviceManagementException e) {
// String msg = "Error occurred while validating the limit of the devices to be returned";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getDevices for groupId: " + groupId; String msg = "Error occurred in getDevices for groupId: " + groupId;
log.error(msg, e); log.error(msg, e);
@ -684,10 +631,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
String msg = "Error occurred while retrieving all groups in tenant"; String msg = "Error occurred while retrieving all groups in tenant";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening a connection to the data source.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getDeviceCount for groupId: " + groupId; String msg = "Error occurred in getDeviceCount for groupId: " + groupId;
log.error(msg, e); log.error(msg, e);
@ -838,18 +781,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GroupManagementDAOFactory.openConnection(); GroupManagementDAOFactory.openConnection();
return groupDAO.getGroups(device.getId(), return groupDAO.getGroups(device.getId(),
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
// } catch (DeviceManagementException e) {
// String msg = "Error occurred while retrieving the device details.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (DeviceManagementException | GroupManagementDAOException | SQLException e) { } catch (DeviceManagementException | GroupManagementDAOException | SQLException e) {
String msg = "Error occurred while retrieving device groups."; String msg = "Error occurred while retrieving device groups.";
log.error(msg, e); log.error(msg, e);
throw new GroupManagementException(msg, e); throw new GroupManagementException(msg, e);
// } catch (SQLException e) {
// String msg = "Error occurred while opening database connection.";
// log.error(msg, e);
// throw new GroupManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getGroups"; String msg = "Error occurred in getGroups";
log.error(msg, e); log.error(msg, e);

@ -42,7 +42,7 @@ import java.util.List;
public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest { public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest {
GroupManagementProviderService groupManagementProviderService; private GroupManagementProviderService groupManagementProviderService;
private static final String DEFAULT_ADMIN_ROLE = "admin"; private static final String DEFAULT_ADMIN_ROLE = "admin";
private static final String[] DEFAULT_ADMIN_PERMISSIONS = {"/permission/device-mgt/admin/groups", private static final String[] DEFAULT_ADMIN_PERMISSIONS = {"/permission/device-mgt/admin/groups",
"/permission/device-mgt/user/groups"}; "/permission/device-mgt/user/groups"};
@ -54,6 +54,7 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
RealmService realmService = new InMemoryRealmService(); RealmService realmService = new InMemoryRealmService();
DeviceManagementDataHolder.getInstance().setRealmService(realmService); DeviceManagementDataHolder.getInstance().setRealmService(realmService);
realmService.getTenantManager().getSuperTenantDomain(); realmService.getTenantManager().getSuperTenantDomain();
DeviceConfigurationManager.getInstance().initConfig();
} }
@Test(expectedExceptions = {GroupManagementException.class, GroupAlreadyExistException.class}) @Test(expectedExceptions = {GroupManagementException.class, GroupAlreadyExistException.class})
@ -71,24 +72,32 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
@Test @Test
public void createGroup() throws GroupManagementException, GroupAlreadyExistException { public void createGroup() throws GroupManagementException, GroupAlreadyExistException {
groupManagementProviderService.createGroup(TestUtils.createDeviceGroup1(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); groupManagementProviderService.createGroup(TestUtils.createDeviceGroup1(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
groupManagementProviderService.createGroup(TestUtils.createDeviceGroup2(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); groupManagementProviderService.createGroup(TestUtils.createDeviceGroup2(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
groupManagementProviderService.createGroup(TestUtils.createDeviceGroup3(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); groupManagementProviderService.createGroup(TestUtils.createDeviceGroup3(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
groupManagementProviderService.createGroup(TestUtils.createDeviceGroup4(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); groupManagementProviderService.createGroup(TestUtils.createDeviceGroup4(), DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
} }
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
public void updateGroup() throws GroupManagementException, GroupNotExistException { public void updateGroup() throws GroupManagementException, GroupNotExistException {
DeviceGroup deviceGroup = groupManagementProviderService.getGroup(TestUtils.createDeviceGroup1().getName()); DeviceGroup deviceGroup = groupManagementProviderService.getGroup(TestUtils.createDeviceGroup1().getName());
deviceGroup.setName(deviceGroup.getName() + "_UPDATED"); deviceGroup.setName(deviceGroup.getName() + "_UPDATED");
groupManagementProviderService.updateGroup(deviceGroup, deviceGroup.getGroupId()); groupManagementProviderService.updateGroup(deviceGroup, deviceGroup.getGroupId());
} }
@Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class})
public void getGroupNull() throws GroupManagementException, GroupNotExistException {
groupManagementProviderService.getGroup(null);
}
// Rename again to use in different place.
@Test(dependsOnMethods = ("updateGroup"))
public void updateGroupSecondTime() throws GroupManagementException, GroupNotExistException {
DeviceGroup deviceGroup = groupManagementProviderService.getGroup(TestUtils.createDeviceGroup1().getName() + "_UPDATED");
deviceGroup.setName(TestUtils.createDeviceGroup1().getName());
groupManagementProviderService.updateGroup(deviceGroup, deviceGroup.getGroupId());
}
@Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class, GroupNotExistException.class}) @Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class, GroupNotExistException.class})
public void updateGroupError() throws GroupManagementException, GroupNotExistException { public void updateGroupError() throws GroupManagementException, GroupNotExistException {
groupManagementProviderService.updateGroup(null, 1); groupManagementProviderService.updateGroup(null, 1);
@ -96,7 +105,6 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
@Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class, GroupNotExistException.class}) @Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class, GroupNotExistException.class})
public void updateGroupErrorNotExist() throws GroupManagementException, GroupNotExistException { public void updateGroupErrorNotExist() throws GroupManagementException, GroupNotExistException {
DeviceGroup deviceGroup = groupManagementProviderService.getGroup(TestUtils.createDeviceGroup2().getName()); DeviceGroup deviceGroup = groupManagementProviderService.getGroup(TestUtils.createDeviceGroup2().getName());
deviceGroup.setName(deviceGroup.getName() + "_UPDATED"); deviceGroup.setName(deviceGroup.getName() + "_UPDATED");
groupManagementProviderService.updateGroup(deviceGroup, 6); groupManagementProviderService.updateGroup(deviceGroup, 6);
@ -141,8 +149,7 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
@Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class}) @Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class})
public void getGroupsByUsernameError() throws GroupManagementException { public void getGroupsByUsernameError() throws GroupManagementException {
String username = null; groupManagementProviderService.getGroups((String) null);
groupManagementProviderService.getGroups(username);
} }
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
@ -158,12 +165,19 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
} }
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
public void getGroupsByUsernameAndPagination(String username, GroupPaginationRequest paginationRequest) public void getGroupsByUsernameAndPagination()
throws GroupManagementException { throws GroupManagementException {
PaginationResult result = groupManagementProviderService.getGroups(username, paginationRequest); PaginationResult result = groupManagementProviderService.getGroups("admin", TestUtils.createPaginationRequest());
Assert.assertNotNull(result); Assert.assertNotNull(result);
} }
@Test(dependsOnMethods = ("createGroup"), expectedExceptions = {GroupManagementException.class})
public void getGroupsByUsernameAndPaginationError()
throws GroupManagementException {
groupManagementProviderService.getGroups(null, TestUtils.createPaginationRequest());
}
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
public void getGroupCount() throws GroupManagementException { public void getGroupCount() throws GroupManagementException {
int x = groupManagementProviderService.getGroupCount(); int x = groupManagementProviderService.getGroupCount();
@ -176,27 +190,28 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
Assert.assertNotNull(x); Assert.assertNotNull(x);
} }
// @Test @Test(dependsOnMethods = ("updateGroupSecondTime"))
// public void manageGroupSharing() throws GroupManagementException, RoleDoesNotExistException, UserStoreException { public void manageGroupSharing() throws GroupManagementException, RoleDoesNotExistException, UserStoreException {
// groupManagementProviderService.manageGroupSharing(0, null); groupManagementProviderService.manageGroupSharing(0, null);
// List<String> newRoles = new ArrayList<>(); List<String> newRoles = new ArrayList<>();
// newRoles.add("TEST_ROLE_1"); newRoles.add("TEST_ROLE_1");
// newRoles.add("TEST_ROLE_2"); newRoles.add("TEST_ROLE_2");
// newRoles.add("TEST_ROLE_3"); newRoles.add("TEST_ROLE_3");
//
// UserStoreManager userStoreManager = UserStoreManager userStoreManager =
// DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(
// -1234).getUserStoreManager(); -1234).getUserStoreManager();
// Permission[] permissions = new Permission[1]; Permission[] permissions = new Permission[1];
// Permission perm = new Permission("/admin/test/perm", "add"); Permission perm = new Permission("/admin/test/perm", "add");
//// perm.setAction("execute.ui"); permissions[0] = perm;
//// perm.setResourceId("/admin/test/perm");
// permissions[0] = perm; userStoreManager.addRole("TEST_ROLE_1", null, permissions);
// userStoreManager.addRole("TEST_ROLE_2", null, permissions);
// userStoreManager.addRole("TEST_ROLE_1", null, permissions); userStoreManager.addRole("TEST_ROLE_3", null, permissions);
//
// groupManagementProviderService.manageGroupSharing(1, newRoles); groupManagementProviderService.manageGroupSharing(groupManagementProviderService.getGroup(
// } TestUtils.createDeviceGroup1().getName()).getGroupId(), newRoles);
}
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
public void getRoles() throws GroupManagementException { public void getRoles() throws GroupManagementException {
@ -216,26 +231,30 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
Assert.assertEquals(0, x); Assert.assertEquals(0, x);
} }
// @Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
// public void addDevices() throws GroupManagementException, DeviceNotFoundException { public void addDevices() throws GroupManagementException, DeviceNotFoundException {
//
// DeviceCacheConfiguration configuration = new DeviceCacheConfiguration(); DeviceCacheConfiguration configuration = new DeviceCacheConfiguration();
// configuration.setEnabled(false); configuration.setEnabled(false);
//
// DeviceConfigurationManager.getInstance().getDeviceManagementConfig().setDeviceCacheConfiguration(configuration); DeviceConfigurationManager.getInstance().getDeviceManagementConfig().setDeviceCacheConfiguration(configuration);
// List<DeviceIdentifier> list = TestUtils.getDeviceIdentifiersList();
// List<DeviceIdentifier> list = TestUtils.getDeviceIdentifiersList(); groupManagementProviderService.addDevices(groupManagementProviderService.getGroup(
// groupManagementProviderService.addDevices(1, list); TestUtils.createDeviceGroup1().getName()).getGroupId(), list);
// groupManagementProviderService.addDevices(2, list); groupManagementProviderService.addDevices(groupManagementProviderService.getGroup(
// groupManagementProviderService.addDevices(3, list); TestUtils.createDeviceGroup2().getName()).getGroupId(), list);
// } groupManagementProviderService.addDevices(groupManagementProviderService.getGroup(
// TestUtils.createDeviceGroup3().getName()).getGroupId(), list);
// @Test(dependsOnMethods = ("addDevices")) }
// public void removeDevice() throws GroupManagementException, DeviceNotFoundException {
// List<DeviceIdentifier> list = TestUtils.getDeviceIdentifiersList(); @Test(dependsOnMethods = ("addDevices"))
// groupManagementProviderService.removeDevice(2, list); public void removeDevice() throws GroupManagementException, DeviceNotFoundException {
// groupManagementProviderService.removeDevice(3, list); List<DeviceIdentifier> list = TestUtils.getDeviceIdentifiersList();
// } groupManagementProviderService.removeDevice(groupManagementProviderService.getGroup(
TestUtils.createDeviceGroup2().getName()).getGroupId(), list);
groupManagementProviderService.removeDevice(groupManagementProviderService.getGroup(
TestUtils.createDeviceGroup3().getName()).getGroupId(), list);
}
@Test(dependsOnMethods = ("createGroup")) @Test(dependsOnMethods = ("createGroup"))
public void getGroupsByUsernameAndPermissions() throws GroupManagementException { public void getGroupsByUsernameAndPermissions() throws GroupManagementException {
@ -243,18 +262,24 @@ public class GroupManagementProviderServiceTest extends BaseDeviceManagementTest
Assert.assertNotNull(groups); Assert.assertNotNull(groups);
} }
// @Test(dependsOnMethods = ("addDevices")) @Test(dependsOnMethods = ("addDevices"))
// public void getGroupsByDeviceIdentifier() throws GroupManagementException { public void getGroupsByDeviceIdentifier() throws GroupManagementException {
// DeviceIdentifier identifier = new DeviceIdentifier(); DeviceIdentifier identifier = new DeviceIdentifier();
// identifier.setId("12345"); identifier.setId("12345");
// identifier.setType("Test"); identifier.setType("Test");
// List<DeviceGroup> groups = groupManagementProviderService.getGroups(identifier); List<DeviceGroup> groups = groupManagementProviderService.getGroups(identifier);
// Assert.assertNull(groups); Assert.assertNotNull(groups);
// } }
@Test @Test
public void createDefaultGroup() throws GroupManagementException { public void createDefaultGroup() throws GroupManagementException {
groupManagementProviderService.createDefaultGroup("BYOD"); groupManagementProviderService.createDefaultGroup("BYOD");
} }
@Test(dependsOnMethods = ("createDefaultGroup"))
public void createDefaultGroupTwice() throws GroupManagementException {
groupManagementProviderService.createDefaultGroup("BYOD");
}
} }

Loading…
Cancel
Save