From 3463d79ae1f1f65ca7ce29dc11ff53d9d1372635 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Mon, 25 Sep 2017 15:31:51 +0530 Subject: [PATCH 1/6] Add operation test case for operation manager. --- .../mgt/core/TestDeviceManagementService.java | 21 +- .../core/common/BaseDeviceManagementTest.java | 53 +- .../mgt/core/common/TestDataHolder.java | 34 +- .../operation/OperationManagementTests.java | 113 ++++ .../resources/carbon-home/dbscripts/h2.sql | 429 +++++++++++++ .../repository/conf/cdm-config.xml | 96 +++ .../carbon-home/repository/conf/registry.xml | 8 +- .../carbon-home/repository/conf/user-mgt.xml | 565 +++++++++--------- .../src/test/resources/sql/h2.sql | 167 +++--- .../user-test/user-mgt-registry-test.xml | 80 +++ 10 files changed, 1136 insertions(+), 430 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/dbscripts/h2.sql create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java index d555de0b41..fca34667aa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java @@ -24,23 +24,38 @@ import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubsc import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import java.util.ArrayList; +import java.util.List; + public class TestDeviceManagementService implements DeviceManagementService { private String providerType; private String tenantDomain; - public TestDeviceManagementService(String deviceType, String tenantDomain){ + public TestDeviceManagementService(String deviceType, String tenantDomain) { providerType = deviceType; this.tenantDomain = tenantDomain; } + @Override public String getType() { return providerType; } @Override - public OperationMonitoringTaskConfig getOperationMonitoringConfig(){ - return null; + public OperationMonitoringTaskConfig getOperationMonitoringConfig() { + OperationMonitoringTaskConfig taskConfig = new OperationMonitoringTaskConfig(); + taskConfig.setEnabled(true); + taskConfig.setFrequency(3000); + List monitoringOperations = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + MonitoringOperation monitoringOperation = new MonitoringOperation(); + monitoringOperation.setTaskName("OPERATION-" + i); + monitoringOperation.setRecurrentTimes(i); + monitoringOperations.add(monitoringOperation); + } + taskConfig.setMonitoringOperation(monitoringOperations); + return taskConfig; } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java index 31f17d81db..f928365c50 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java @@ -32,6 +32,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.core.TestUtils; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import javax.sql.DataSource; @@ -60,6 +61,7 @@ public abstract class BaseDeviceManagementTest { this.dataSource = this.getDataSource(this.readDataSourceConfig()); DeviceManagementDAOFactory.init(dataSource); GroupManagementDAOFactory.init(dataSource); + OperationManagementDAOFactory.init(dataSource); } @BeforeClass @@ -130,15 +132,13 @@ public abstract class BaseDeviceManagementTest { try { conn = getDataSource().getConnection(); conn.setAutoCommit(false); - - //TODO:FIX ME -// this.cleanupEnrolmentData(conn); -// this.cleanApplicationMappingData(conn); -// this.cleanApplicationData(conn); -// this.cleanupDeviceData(conn); -// this.cleanupDeviceTypeData(conn); - this.cleanupGroupData(conn); - + String[] cleanupTables = new String[]{"DM_ENROLMENT_OP_MAPPING", "DM_CONFIG_OPERATION", + "DM_POLICY_OPERATION", "DM_COMMAND_OPERATION", "DM_PROFILE_OPERATION", "DM_DEVICE_GROUP_MAP", + "DM_GROUP", "DM_ENROLMENT", "DM_DEVICE_APPLICATION_MAPPING", + "DM_APPLICATION", "DM_DEVICE", "DM_DEVICE_TYPE"}; + for (String table : cleanupTables) { + this.cleanData(conn, table); + } conn.commit(); } catch (SQLException e) { try { @@ -162,39 +162,8 @@ public abstract class BaseDeviceManagementTest { } } - private void cleanApplicationMappingData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_DEVICE_APPLICATION_MAPPING")) { - stmt.execute(); - } - } - - private void cleanApplicationData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_APPLICATION")) { - stmt.execute(); - } - } - - - private void cleanupEnrolmentData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_ENROLMENT")) { - stmt.execute(); - } - } - - private void cleanupDeviceData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_DEVICE")) { - stmt.execute(); - } - } - - private void cleanupDeviceTypeData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_DEVICE_TYPE")) { - stmt.execute(); - } - } - - private void cleanupGroupData(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM DM_GROUP")) { + private void cleanData(Connection conn, String tableName) throws SQLException { + try (PreparedStatement stmt = conn.prepareStatement("DELETE FROM " + tableName)) { stmt.execute(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java index 812e7c5cf8..180fae6b1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDataHolder.java @@ -16,12 +16,15 @@ package org.wso2.carbon.device.mgt.core.common; import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Properties; public class TestDataHolder { @@ -34,8 +37,7 @@ public class TestDataHolder { public static Device initialTestDevice; public static DeviceType initialTestDeviceType; - public static Device generateDummyDeviceData(String deviceType){ - + public static Device generateDummyDeviceData(String deviceType) { Device device = new Device(); EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setDateOfEnrolment(new Date().getTime()); @@ -50,18 +52,35 @@ public class TestDataHolder { return device; } - public static DeviceType generateDeviceTypeData(String devTypeName){ + public static List generateDummyDeviceData(List deviceIds) { + List devices = new ArrayList<>(); + for (DeviceIdentifier deviceId : deviceIds) { + Device device = new Device(); + EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + enrolmentInfo.setDateOfEnrolment(new Date().getTime()); + enrolmentInfo.setDateOfLastUpdate(new Date().getTime()); + enrolmentInfo.setOwner(OWNER); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); + enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED); + device.setEnrolmentInfo(enrolmentInfo); + device.setDescription("Test Description"); + device.setDeviceIdentifier(deviceId.getId()); + device.setType(deviceId.getType()); + devices.add(device); + } + return devices; + } + + public static DeviceType generateDeviceTypeData(String devTypeName) { DeviceType deviceType = new DeviceType(); deviceType.setName(devTypeName); return deviceType; } - public static Application generateApplicationDummyData(String appIdentifier){ - + public static Application generateApplicationDummyData(String appIdentifier) { Application application = new Application(); Properties properties = new Properties(); - properties.setProperty("test1","testVal"); - + properties.setProperty("test1", "testVal"); application.setName("SimpleCalculator"); application.setCategory("TestCategory"); application.setApplicationIdentifier(appIdentifier); @@ -70,7 +89,6 @@ public class TestDataHolder { application.setImageUrl("http://test.org/image/"); application.setLocationUrl("http://test.org/location/"); application.setAppProperties(properties); - return application; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java new file mode 100644 index 0000000000..9547ea6cca --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.wso2.carbon.device.mgt.core.operation; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +import org.wso2.carbon.device.mgt.core.TestDeviceManagementService; +import org.wso2.carbon.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; +import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; +import org.wso2.carbon.device.mgt.core.common.TestDataHolder; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; +import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagementServiceProvider; +import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.wso2.carbon.registry.core.config.RegistryContext; +import org.wso2.carbon.registry.core.exceptions.RegistryException; +import org.wso2.carbon.registry.core.internal.RegistryDataHolder; +import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService; +import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class OperationManagementTests extends BaseDeviceManagementTest { + private static final Log log = LogFactory.getLog(OperationManagementTests.class); + + private static final String DEVICE_TYPE = "OP_TEST_TYPE"; + private static final String DEVICE_ID_PREFIX = "OP-TEST-DEVICE-ID-"; + private static final String COMMAND_OPERATON_CODE = "COMMAND-TEST"; + + private List deviceIds = new ArrayList<>(); + private DeviceManagementProviderService deviceMgtService; + private OperationManager operationMgtService; + + @BeforeClass + @Override + public void init() throws Exception { + DeviceConfigurationManager.getInstance().initConfig(); + initDataSource(); + log.info("Initializing"); + for (int i = 0; i < 5; i++) { + deviceIds.add(new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE)); + } + List devices = TestDataHolder.generateDummyDeviceData(this.deviceIds); + this.deviceMgtService = new DeviceManagementProviderServiceImpl(); + DeviceManagementServiceComponent.notifyStartupListeners(); + DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService); + DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService()); + DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl()); + this.deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); + for (Device device : devices) { + this.deviceMgtService.enrollDevice(device); + } + List returnedDevices = this.deviceMgtService.getAllDevices(DEVICE_TYPE); + for (Device device : returnedDevices) { + if (!device.getDeviceIdentifier().startsWith(DEVICE_ID_PREFIX)) { + throw new Exception("Incorrect device with ID - " + device.getDeviceIdentifier() + " returned!"); + } + } + + this.operationMgtService = new OperationManagerImpl(DEVICE_TYPE); + } + + private RegistryService getRegistryService() throws RegistryException { + RealmService realmService = new InMemoryRealmService(); + RegistryDataHolder.getInstance().setRealmService(realmService); + InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml"); + RegistryContext context = RegistryContext.getBaseInstance(is, realmService); + context.setSetup(true); + return context.getEmbeddedRegistryService(); + } + + @Test + public void addCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + CommandOperation operation = new CommandOperation(); + operation.setType(Operation.Type.PROFILE); + operation.setCode(COMMAND_OPERATON_CODE); + this.operationMgtService.addOperation(operation, this.deviceIds); + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/dbscripts/h2.sql new file mode 100644 index 0000000000..f6b31c78d9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/dbscripts/h2.sql @@ -0,0 +1,429 @@ +CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK ( + REG_LOCK_NAME VARCHAR (20), + REG_LOCK_STATUS VARCHAR (20), + REG_LOCKED_TIME TIMESTAMP, + REG_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (REG_LOCK_NAME) +); + +CREATE TABLE IF NOT EXISTS REG_LOG ( + REG_LOG_ID INTEGER AUTO_INCREMENT, + REG_PATH VARCHAR (2000), + REG_USER_ID VARCHAR (31) NOT NULL, + REG_LOGGED_TIME TIMESTAMP NOT NULL, + REG_ACTION INTEGER NOT NULL, + REG_ACTION_DATA VARCHAR (500), + REG_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (REG_LOG_ID, REG_TENANT_ID) +); + +CREATE INDEX IF NOT EXISTS REG_LOG_IND_BY_REG_LOGTIME ON REG_LOG(REG_LOGGED_TIME, REG_TENANT_ID); + +CREATE TABLE IF NOT EXISTS REG_PATH( + REG_PATH_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_PATH_VALUE VARCHAR(2000) NOT NULL, + REG_PATH_PARENT_ID INT, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_PATH PRIMARY KEY(REG_PATH_ID, REG_TENANT_ID) +); +CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_NAME ON REG_PATH(REG_PATH_VALUE, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_PARENT_ID ON REG_PATH(REG_PATH_PARENT_ID, REG_TENANT_ID); + + +CREATE TABLE IF NOT EXISTS REG_CONTENT ( + REG_CONTENT_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_CONTENT_DATA LONGBLOB, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_CONTENT PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_CONTENT_HISTORY ( + REG_CONTENT_ID INTEGER NOT NULL, + REG_CONTENT_DATA LONGBLOB, + REG_DELETED SMALLINT, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_CONTENT_HISTORY PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE ( + REG_PATH_ID INTEGER NOT NULL, + REG_NAME VARCHAR(256), + REG_VERSION INTEGER NOT NULL AUTO_INCREMENT, + REG_MEDIA_TYPE VARCHAR(500), + REG_CREATOR VARCHAR(31) NOT NULL, + REG_CREATED_TIME TIMESTAMP NOT NULL, + REG_LAST_UPDATOR VARCHAR(31), + REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL, + REG_DESCRIPTION VARCHAR(1000), + REG_CONTENT_ID INTEGER, + REG_TENANT_ID INTEGER DEFAULT 0, + REG_UUID VARCHAR(100) NOT NULL, + CONSTRAINT PK_REG_RESOURCE PRIMARY KEY(REG_VERSION, REG_TENANT_ID) +); + +ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT (REG_CONTENT_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_NAME ON REG_RESOURCE(REG_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_UUID ON REG_RESOURCE(REG_UUID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TENANT ON REG_RESOURCE(REG_TENANT_ID, REG_UUID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TYPE ON REG_RESOURCE(REG_TENANT_ID, REG_MEDIA_TYPE); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE_HISTORY ( + REG_PATH_ID INTEGER NOT NULL, + REG_NAME VARCHAR(256), + REG_VERSION INTEGER NOT NULL, + REG_MEDIA_TYPE VARCHAR(500), + REG_CREATOR VARCHAR(31) NOT NULL, + REG_CREATED_TIME TIMESTAMP NOT NULL, + REG_LAST_UPDATOR VARCHAR(31), + REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL, + REG_DESCRIPTION VARCHAR(1000), + REG_CONTENT_ID INTEGER, + REG_DELETED SMALLINT, + REG_TENANT_ID INTEGER DEFAULT 0, + REG_UUID VARCHAR(100) NOT NULL, + CONSTRAINT PK_REG_RESOURCE_HISTORY PRIMARY KEY(REG_VERSION, REG_TENANT_ID) +); + +ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_PATHID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT_HISTORY (REG_CONTENT_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_NAME ON REG_RESOURCE_HISTORY(REG_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID); + +CREATE TABLE IF NOT EXISTS REG_COMMENT ( + REG_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_COMMENT_TEXT VARCHAR(500) NOT NULL, + REG_USER_ID VARCHAR(31) NOT NULL, + REG_COMMENTED_TIME TIMESTAMP NOT NULL, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_COMMENT PRIMARY KEY(REG_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE_COMMENT ( + REG_COMMENT_ID INTEGER NOT NULL, + REG_VERSION INTEGER, + REG_PATH_ID INTEGER, + REG_RESOURCE_NAME VARCHAR(256), + REG_TENANT_ID INTEGER DEFAULT 0 +); + +ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_COMMENT_ID FOREIGN KEY (REG_COMMENT_ID, REG_TENANT_ID) REFERENCES REG_COMMENT (REG_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_COMMENT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_VERSION ON REG_RESOURCE_COMMENT(REG_VERSION, REG_TENANT_ID); + +CREATE TABLE IF NOT EXISTS REG_RATING ( + REG_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_RATING INTEGER NOT NULL, + REG_USER_ID VARCHAR(31) NOT NULL, + REG_RATED_TIME TIMESTAMP NOT NULL, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_RATING PRIMARY KEY(REG_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE_RATING ( + REG_RATING_ID INTEGER NOT NULL, + REG_VERSION INTEGER, + REG_PATH_ID INTEGER, + REG_RESOURCE_NAME VARCHAR(256), + REG_TENANT_ID INTEGER DEFAULT 0 +); + +ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_RATING_ID FOREIGN KEY (REG_RATING_ID, REG_TENANT_ID) REFERENCES REG_RATING (REG_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_RATING(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_VERSION ON REG_RESOURCE_RATING(REG_VERSION, REG_TENANT_ID); + + +CREATE TABLE IF NOT EXISTS REG_TAG ( + REG_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_TAG_NAME VARCHAR(500) NOT NULL, + REG_USER_ID VARCHAR(31) NOT NULL, + REG_TAGGED_TIME TIMESTAMP NOT NULL, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_TAG PRIMARY KEY(REG_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE_TAG ( + REG_TAG_ID INTEGER NOT NULL, + REG_VERSION INTEGER, + REG_PATH_ID INTEGER, + REG_RESOURCE_NAME VARCHAR(256), + REG_TENANT_ID INTEGER DEFAULT 0 +); + +ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_TAG_ID FOREIGN KEY (REG_TAG_ID, REG_TENANT_ID) REFERENCES REG_TAG (REG_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_TAG(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_VERSION ON REG_RESOURCE_TAG(REG_VERSION, REG_TENANT_ID); + +CREATE TABLE IF NOT EXISTS REG_PROPERTY ( + REG_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_NAME VARCHAR(100) NOT NULL, + REG_VALUE VARCHAR(1000), + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_PROPERTY PRIMARY KEY(REG_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_RESOURCE_PROPERTY ( + REG_PROPERTY_ID INTEGER NOT NULL, + REG_VERSION INTEGER, + REG_PATH_ID INTEGER, + REG_RESOURCE_NAME VARCHAR(256), + REG_TENANT_ID INTEGER DEFAULT 0 +); + +ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_TAG_ID FOREIGN KEY (REG_PROPERTY_ID, REG_TENANT_ID) REFERENCES REG_PROPERTY (REG_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_PROPERTY(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_VERSION ON REG_RESOURCE_PROPERTY(REG_VERSION, REG_TENANT_ID); + +CREATE TABLE IF NOT EXISTS REG_ASSOCIATION ( + REG_ASSOCIATION_ID INTEGER AUTO_INCREMENT, + REG_SOURCEPATH VARCHAR (2000) NOT NULL, + REG_TARGETPATH VARCHAR (2000) NOT NULL, + REG_ASSOCIATION_TYPE VARCHAR (2000) NOT NULL, + REG_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (REG_ASSOCIATION_ID, REG_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS REG_SNAPSHOT ( + REG_SNAPSHOT_ID INTEGER NOT NULL AUTO_INCREMENT, + REG_PATH_ID INTEGER NOT NULL, + REG_RESOURCE_NAME VARCHAR (256), + REG_RESOURCE_VIDS LONGBLOB NOT NULL, + REG_TENANT_ID INTEGER DEFAULT 0, + CONSTRAINT PK_REG_SNAPSHOT PRIMARY KEY(REG_SNAPSHOT_ID, REG_TENANT_ID) +); + +ALTER TABLE REG_SNAPSHOT ADD CONSTRAINT IF NOT EXISTS REG_SNAPSHOT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID); +CREATE INDEX IF NOT EXISTS REG_SNAPSHOT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_SNAPSHOT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID); + +-- ################################ +-- USER MANAGER TABLES +-- ################################ + +CREATE TABLE IF NOT EXISTS UM_TENANT ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE BOOLEAN DEFAULT FALSE, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG LONGBLOB NOT NULL, + PRIMARY KEY (UM_ID), + UNIQUE(UM_DOMAIN_NAME)); + +CREATE TABLE IF NOT EXISTS UM_DOMAIN( + UM_DOMAIN_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DOMAIN_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID) +); + +CREATE INDEX IF NOT EXISTS INDEX_UM_TENANT_UM_DOMAIN_NAME ON UM_TENANT (UM_DOMAIN_NAME); + +CREATE TABLE IF NOT EXISTS UM_USER ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID)); + +CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID)); + +CREATE TABLE IF NOT EXISTS UM_USER_ATTRIBUTE ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ATTR_NAME VARCHAR(255) NOT NULL, + UM_ATTR_VALUE VARCHAR(1024), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID)); + +CREATE INDEX IF NOT EXISTS UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID); + +CREATE TABLE IF NOT EXISTS UM_ROLE ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE BOOLEAN DEFAULT FALSE, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME, UM_TENANT_ID)); + +CREATE TABLE IF NOT EXISTS UM_MODULE( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_MODULE_NAME VARCHAR(100), + UNIQUE(UM_MODULE_NAME), + PRIMARY KEY(UM_ID) +); + +CREATE TABLE IF NOT EXISTS UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS UM_PERMISSION ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_RESOURCE_ID VARCHAR(255) NOT NULL, + UM_ACTION VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)); + +CREATE INDEX IF NOT EXISTS INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID); + +CREATE TABLE IF NOT EXISTS UM_ROLE_PERMISSION ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)); + +CREATE TABLE IF NOT EXISTS UM_USER_PERMISSION ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)); + +CREATE TABLE IF NOT EXISTS UM_USER_ROLE ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)); + + +CREATE TABLE IF NOT EXISTS UM_SHARED_USER_ROLE( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS UM_ACCOUNT_MAPPING( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +); + + +CREATE TABLE IF NOT EXISTS UM_DIALECT( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + + +CREATE TABLE IF NOT EXISTS UM_CLAIM( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_ID INTEGER NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI,UM_MAPPED_ATTRIBUTE_DOMAIN, UM_TENANT_ID), + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS UM_PROFILE_CONFIG( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_ID INTEGER, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + + +CREATE TABLE IF NOT EXISTS UM_HYBRID_ROLE( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS UM_HYBRID_USER_ROLE( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID,UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS UM_HYBRID_REMEMBER_ME ( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS UM_SYSTEM_ROLE( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER_ROLE( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml new file mode 100644 index 0000000000..58ed4e6167 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -0,0 +1,96 @@ + + + + + + + + jdbc/DM_DS + + + + + 1000 + 60000 + 60000 + true + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + + + + false + + + https://localhost:9443 + admin + admin + + + org.wso2.carbon.policy.mgt + true + 60000 + 5 + 8 + 20 + + + + Simple + + + + 20 + 20 + 20 + 20 + 20 + 20 + + + + true + + + + true + 600 + + 10000 + + + true + 86400 + + + false + false + + BYOD,COPE + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/registry.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/registry.xml index 6b13a376ce..85d422c704 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/registry.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/registry.xml @@ -28,7 +28,13 @@ / - jdbc/WSO2CarbonDB + jdbc:h2:./target/databasetest/CARBON_TEST + + org.h2.Driver + 80 + 60000 + 5 - + - true - admin - - admin - admin - + true + admin + + admin + admin + everyone jdbc/WSO2CarbonDB - - + + - + org.wso2.carbon.user.core.tenant.JDBCTenantManager - false + false 100 false default SHA-256 true true - true + true false ^[\S]{5,30}$ - Password length should be between 5 to 30 characters + Password length should be between 5 to 30 characters + ^[\S]{5,30}$ [a-zA-Z0-9._-|//]{3,30}$ - ^[\S]{3,30}$ - ^[^~!#$;%^*+={}\\|\\\\<>,\'\"]{3,30}$ - ^[\S]{3,30}$ + ^[\S]{3,30}$ + ^[^~!#$;%^*+={}\\|\\\\<>,\'\"]{3,30}$ + ^[\S]{3,30}$ true 100 100 - false + false false true , true - - + + - - - - - - + + CN=Users,DC=WSO2,DC=Com + user + cn + memberOf + follow + false + 512 + (objectClass=user) + (&(objectClass=user)(cn=?)) + [a-zA-Z0-9._-|//]{3,30}$ + ^[\S]{3,30}$ + ^[\S]{5,30}$ + Password length should be between 5 to 30 characters + ^[\S]{5,30}$ + ^[\S]{3,30}$ + [a-zA-Z0-9._-|//]{3,30}$ + true + true + true + CN=Users,DC=WSO2,DC=Com + group + cn + cn + ou=SharedGroups,dc=wso2,dc=org + groups + (object=organizationalUnit) + ou + organizationalUnit + member + (objectcategory=group) + (&(objectClass=group)(cn=?)) + true + follow + true + 100 + 100 + false + false + , + true + - - + + [a-zA-Z0-9._-|//]{3,30}$ + ^[\S]{5,30}$ + ^[\S]{5,30}$ + Password length should be between 5 to 30 characters + true + true + false + ou=system + (objectClass=groupOfNames) + groupOfNames + (&(objectClass=groupOfNames)(cn=?)) + cn + cn + ou=SharedGroups,dc=wso2,dc=org + groupOfNames + (objectClass=groupOfNames) + (&(objectClass=groupOfNames)(cn=?)) + (objectClass=organizationalUnit) + ou + organizationalUnit + member + true + true + 100 + 100 + false + false + , + true + + + + - - + And if this CassandraUserStoreManager is used as the primary user store with multi tenants, it should also implement a + compatible TenantManager and set property FULL_QUALIFIED_TENANT_MANAGER_CLASS_NAME. + --> + + class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager"> /permission - true - true + true + true - + DisplayNameAttribute - this is to have a dedicated LDAP attribute to display an entity(User/Role) in UI, in addition to the UserNameAttribute which is used for IS-UserStore interactions. + --> diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql index dadee68128..068c97664c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql @@ -24,15 +24,7 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_GROUP_MAP ( TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT fk_DM_ROLE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION -); - -CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( - ID INTEGER auto_increment NOT NULL, - SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, - CERTIFICATE BLOB DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID) + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE IF NOT EXISTS DM_DEVICE ( @@ -44,8 +36,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_DM_DEVICE UNIQUE (NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( + DEVICE_TYPE_NAME VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) ); CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( @@ -55,9 +57,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID) - REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + REFERENCES DM_DEVICE (ID) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE IF NOT EXISTS DM_OPERATION ( @@ -72,6 +74,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION ( OPERATION_ID INTEGER NOT NULL, OPERATION_CONFIG BLOB DEFAULT NULL, + ENABLED BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (OPERATION_ID), CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION @@ -114,7 +117,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( TENANT_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -122,6 +126,9 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, STATUS VARCHAR(50) NULL, + PUSH_NOTIFICATION_STATUS VARCHAR(50) NULL, + CREATED_TIMESTAMP INT NOT NULL, + UPDATED_TIMESTAMP INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -133,12 +140,16 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, + EN_OP_MAP_ID INTEGER NOT NULL, OPERATION_RESPONSE LONGBLOB DEFAULT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_operation_response_enrollment FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_operation_response_operation FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_en_op_map_response FOREIGN KEY (EN_OP_MAP_ID) REFERENCES + DM_ENROLMENT_OP_MAPPING (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- POLICY RELATED TABLES -- @@ -147,21 +158,12 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID INT NOT NULL AUTO_INCREMENT , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INT NOT NULL , - DEVICE_TYPE_ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); - - - - CREATE TABLE IF NOT EXISTS DM_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , @@ -181,9 +183,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , DEVICE_ID INT(11) NOT NULL , @@ -203,35 +202,23 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ID INT(11) NOT NULL , - DEVICE_TYPE_ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) - ON DELETE NO ACTION ON UPDATE NO ACTION ); - - - - CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID INT(11) NOT NULL AUTO_INCREMENT, PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), @@ -242,9 +229,6 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , @@ -257,9 +241,6 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ID INT NOT NULL AUTO_INCREMENT , POLICY_ID INT NOT NULL , @@ -272,8 +253,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ON UPDATE NO ACTION ); - - CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( +CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, @@ -292,8 +272,6 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ON UPDATE NO ACTION ); - - CREATE TABLE IF NOT EXISTS DM_CRITERIA ( ID INT NOT NULL AUTO_INCREMENT, TENANT_ID INT NOT NULL, @@ -301,8 +279,6 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA ( PRIMARY KEY (ID) ); - - CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( ID INT NOT NULL AUTO_INCREMENT, CRITERIA_ID INT NOT NULL, @@ -348,16 +324,14 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( PRIMARY KEY (ID) ); - CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); - CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( ID INT NOT NULL AUTO_INCREMENT, COMPLIANCE_STATUS_ID INT NOT NULL, @@ -372,20 +346,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( ON UPDATE NO ACTION ); -CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( - ID INTEGER AUTO_INCREMENT NOT NULL, - DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(50) NOT NULL, - OWNERSHIP VARCHAR(45) DEFAULT NULL, - STATUS VARCHAR(50) NULL, - DATE_OF_ENROLMENT TIMESTAMP DEFAULT NULL, - DATE_OF_LAST_UPDATE TIMESTAMP DEFAULT NULL, - TENANT_ID INT NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION -); - CREATE TABLE IF NOT EXISTS DM_APPLICATION ( ID INTEGER AUTO_INCREMENT NOT NULL, NAME VARCHAR(150) NOT NULL, @@ -424,7 +384,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( OPERATION_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(100) NULL, + DESCRIPTION VARCHAR(1000) NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -433,8 +393,6 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( ); -- NOTIFICATION TABLE END -- -DROP TABLE IF EXISTS DM_DEVICE_INFO; - CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -448,10 +406,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ON UPDATE NO ACTION ); - - -DROP TABLE IF EXISTS DM_DEVICE_LOCATION; - CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -472,7 +426,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON UPDATE NO ACTION ); - CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, @@ -500,9 +453,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ON UPDATE NO ACTION ); - -- POLICY AND DEVICE GROUP MAPPING -- - CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_GROUP_ID INT NOT NULL, @@ -512,20 +463,21 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, + ON DELETE CASCADE + ON UPDATE CASCADE , CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY - FOREIGN KEY (POLICY_ID , DEVICE_GROUP_ID) - REFERENCES DM_POLICY (ID , ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE CASCADE + ON UPDATE CASCADE ); - -- END OF POLICY AND DEVICE GROUP MAPPING -- -CREATE VIEW DEVICES_VIEW_1 AS +-- DASHBOARD RELATED VIEWS -- +CREATE VIEW POLICY_COMPLIANCE_INFO AS SELECT DEVICE_INFO.DEVICE_ID, +DEVICE_INFO.DEVICE_IDENTIFICATION, DEVICE_INFO.PLATFORM, DEVICE_INFO.OWNERSHIP, DEVICE_INFO.CONNECTIVITY_STATUS, @@ -535,10 +487,11 @@ DEVICE_INFO.TENANT_ID FROM (SELECT DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, DM_DEVICE_TYPE.NAME AS PLATFORM, -DM_ENROLMENT.OWNERSHIP AS OWNERSHIP, +DM_ENROLMENT.OWNERSHIP, DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, -DM_DEVICE.TENANT_ID AS TENANT_ID +DM_DEVICE.TENANT_ID FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) DEVICE_INFO LEFT JOIN @@ -546,7 +499,33 @@ LEFT JOIN DEVICE_ID, POLICY_ID, STATUS AS IS_COMPLIANT -FROM -DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO +FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID ORDER BY DEVICE_INFO.DEVICE_ID; + +CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml new file mode 100644 index 0000000000..ebc6ed4cfc --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -0,0 +1,80 @@ + + + + + true + admin + + admin + admin + + everyone + false + 500 + jdbc:h2:target/databasetest/CARBON_TEST + org.h2.Driver + 50 + 60000 + 5 + + + org.wso2.carbon.user.core.tenant.JDBCTenantManager + false + 100 + false + default + SHA-256 + true + true + true + false + ^[\S]{5,30}$ + Password length should be between 5 to 30 characters + + ^[\S]{5,30}$ + [a-zA-Z0-9._-|//]{3,30}$ + ^[\S]{3,30}$ + ^[^~!#$;%^*+={}\\|\\\\<>,\'\"]{3,30}$ + ^[\S]{3,30}$ + true + 100 + 100 + false + false + true + , + true + + + true + + + + login + manage-configuration + manage-security + upload-services + manage-services + manage-lc-configuration + manage-mediation + monitor-system + delegate-identity + + From cb92f6ef65b0887bd3946a62e6a523ce75813d89 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Mon, 25 Sep 2017 16:02:11 +0530 Subject: [PATCH 2/6] Adding more tests for operation manager. --- .../operation/OperationManagementTests.java | 62 ++++++++++++++----- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java index 9547ea6cca..676631bc6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.core.operation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.Device; @@ -35,22 +36,21 @@ import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagementServiceProvider; -import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; +import org.wso2.carbon.device.mgt.core.operation.mgt.*; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; -import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService; import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class OperationManagementTests extends BaseDeviceManagementTest { @@ -59,9 +59,12 @@ public class OperationManagementTests extends BaseDeviceManagementTest { private static final String DEVICE_TYPE = "OP_TEST_TYPE"; private static final String DEVICE_ID_PREFIX = "OP-TEST-DEVICE-ID-"; private static final String COMMAND_OPERATON_CODE = "COMMAND-TEST"; + private static final String POLICY_OPERATION_CODE = "POLICY-TEST"; + private static final String CONFIG_OPERATION_CODE = "CONFIG-TEST"; + private static final String PROFILE_OPERATION_CODE = "PROFILE-TEST"; + private static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; private List deviceIds = new ArrayList<>(); - private DeviceManagementProviderService deviceMgtService; private OperationManager operationMgtService; @BeforeClass @@ -74,23 +77,22 @@ public class OperationManagementTests extends BaseDeviceManagementTest { deviceIds.add(new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE)); } List devices = TestDataHolder.generateDummyDeviceData(this.deviceIds); - this.deviceMgtService = new DeviceManagementProviderServiceImpl(); + DeviceManagementProviderService deviceMgtService = new DeviceManagementProviderServiceImpl(); DeviceManagementServiceComponent.notifyStartupListeners(); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService); DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService()); DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl()); - this.deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, + deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); for (Device device : devices) { - this.deviceMgtService.enrollDevice(device); + deviceMgtService.enrollDevice(device); } - List returnedDevices = this.deviceMgtService.getAllDevices(DEVICE_TYPE); + List returnedDevices = deviceMgtService.getAllDevices(DEVICE_TYPE); for (Device device : returnedDevices) { if (!device.getDeviceIdentifier().startsWith(DEVICE_ID_PREFIX)) { throw new Exception("Incorrect device with ID - " + device.getDeviceIdentifier() + " returned!"); } } - this.operationMgtService = new OperationManagerImpl(DEVICE_TYPE); } @@ -105,9 +107,41 @@ public class OperationManagementTests extends BaseDeviceManagementTest { @Test public void addCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - CommandOperation operation = new CommandOperation(); - operation.setType(Operation.Type.PROFILE); - operation.setCode(COMMAND_OPERATON_CODE); - this.operationMgtService.addOperation(operation, this.deviceIds); + this.operationMgtService.addOperation(getOperation(new CommandOperation(), Operation.Type.COMMAND, COMMAND_OPERATON_CODE), + this.deviceIds); + } + + @Test(dependsOnMethods = "addCommandOperation") + public void addPolicyOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + this.operationMgtService.addOperation(getOperation(new PolicyOperation(), Operation.Type.POLICY, PROFILE_OPERATION_CODE), + this.deviceIds); + } + + @Test(dependsOnMethods = "addPolicyOperation") + public void addConfigOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + this.operationMgtService.addOperation(getOperation(new ConfigOperation(), Operation.Type.CONFIG, CONFIG_OPERATION_CODE), + this.deviceIds); + } + + @Test(dependsOnMethods = "addConfigOperation") + public void addProfileOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + this.operationMgtService.addOperation(getOperation(new ProfileOperation(), Operation.Type.PROFILE, PROFILE_OPERATION_CODE), + this.deviceIds); + } + + private Operation getOperation(Operation operation, Operation.Type type, String code) { + String date = new SimpleDateFormat(DATE_FORMAT_NOW).format(new Date()); + operation.setCreatedTimeStamp(date); + operation.setType(type); + operation.setCode(code); + return operation; + } + + @Test(dependsOnMethods = "addProfileOperation") + public void verifyCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + for (DeviceIdentifier deviceIdentifier : deviceIds) { + List operations = this.operationMgtService.getPendingOperations(deviceIdentifier); + Assert.assertEquals(operations.size(), 4, "The pending operations should be 4, but found only " + operations.size()); + } } } From f9bc4d04ad64514bc0e599d410892a8ffe68c71a Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 26 Sep 2017 13:29:45 +0530 Subject: [PATCH 3/6] Adding first set of operation management testcases. --- .../core/common/BaseDeviceManagementTest.java | 6 +- .../operation/OperationManagementTests.java | 100 ++++++++++++++++-- 2 files changed, 96 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java index f928365c50..5f139d326d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java @@ -57,7 +57,7 @@ public abstract class BaseDeviceManagementTest { this.initializeCarbonContext(); } - public void initDataSource() throws Exception { + protected void initDataSource() throws Exception { this.dataSource = this.getDataSource(this.readDataSourceConfig()); DeviceManagementDAOFactory.init(dataSource); GroupManagementDAOFactory.init(dataSource); @@ -132,7 +132,7 @@ public abstract class BaseDeviceManagementTest { try { conn = getDataSource().getConnection(); conn.setAutoCommit(false); - String[] cleanupTables = new String[]{"DM_ENROLMENT_OP_MAPPING", "DM_CONFIG_OPERATION", + String[] cleanupTables = new String[]{"DM_DEVICE_OPERATION_RESPONSE","DM_ENROLMENT_OP_MAPPING", "DM_CONFIG_OPERATION", "DM_POLICY_OPERATION", "DM_COMMAND_OPERATION", "DM_PROFILE_OPERATION", "DM_DEVICE_GROUP_MAP", "DM_GROUP", "DM_ENROLMENT", "DM_DEVICE_APPLICATION_MAPPING", "DM_APPLICATION", "DM_DEVICE", "DM_DEVICE_TYPE"}; @@ -168,7 +168,7 @@ public abstract class BaseDeviceManagementTest { } } - public DataSource getDataSource() { + protected DataSource getDataSource() { return dataSource; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java index 676631bc6d..f205725565 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java @@ -15,6 +15,7 @@ * under the License. * */ + package org.wso2.carbon.device.mgt.core.operation; import org.apache.commons.logging.Log; @@ -22,10 +23,15 @@ import org.apache.commons.logging.LogFactory; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; @@ -36,9 +42,14 @@ import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; -import org.wso2.carbon.device.mgt.core.operation.mgt.*; +import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; +import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; @@ -63,6 +74,9 @@ public class OperationManagementTests extends BaseDeviceManagementTest { private static final String CONFIG_OPERATION_CODE = "CONFIG-TEST"; private static final String PROFILE_OPERATION_CODE = "PROFILE-TEST"; private static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; + private static final int NO_OF_DEVICES = 5; + private static final String ADMIN_USER = "admin"; + private static final String NON_ADMIN_USER = "test"; private List deviceIds = new ArrayList<>(); private OperationManager operationMgtService; @@ -73,7 +87,7 @@ public class OperationManagementTests extends BaseDeviceManagementTest { DeviceConfigurationManager.getInstance().initConfig(); initDataSource(); log.info("Initializing"); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < NO_OF_DEVICES; i++) { deviceIds.add(new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE)); } List devices = TestDataHolder.generateDummyDeviceData(this.deviceIds); @@ -82,6 +96,7 @@ public class OperationManagementTests extends BaseDeviceManagementTest { DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService); DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService()); DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl()); + DeviceManagementDataHolder.getInstance().setGroupManagementProviderService(new GroupManagementProviderServiceImpl()); deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); for (Device device : devices) { @@ -99,6 +114,7 @@ public class OperationManagementTests extends BaseDeviceManagementTest { private RegistryService getRegistryService() throws RegistryException { RealmService realmService = new InMemoryRealmService(); RegistryDataHolder.getInstance().setRealmService(realmService); + DeviceManagementDataHolder.getInstance().setRealmService(realmService); InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml"); RegistryContext context = RegistryContext.getBaseInstance(is, realmService); context.setSetup(true); @@ -107,26 +123,30 @@ public class OperationManagementTests extends BaseDeviceManagementTest { @Test public void addCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - this.operationMgtService.addOperation(getOperation(new CommandOperation(), Operation.Type.COMMAND, COMMAND_OPERATON_CODE), + Activity activity = this.operationMgtService.addOperation(getOperation(new CommandOperation(), Operation.Type.COMMAND, COMMAND_OPERATON_CODE), this.deviceIds); + validateOperationResponse(activity); } @Test(dependsOnMethods = "addCommandOperation") public void addPolicyOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - this.operationMgtService.addOperation(getOperation(new PolicyOperation(), Operation.Type.POLICY, PROFILE_OPERATION_CODE), + Activity activity = this.operationMgtService.addOperation(getOperation(new PolicyOperation(), Operation.Type.POLICY, POLICY_OPERATION_CODE), this.deviceIds); + validateOperationResponse(activity); } @Test(dependsOnMethods = "addPolicyOperation") public void addConfigOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - this.operationMgtService.addOperation(getOperation(new ConfigOperation(), Operation.Type.CONFIG, CONFIG_OPERATION_CODE), + Activity activity = this.operationMgtService.addOperation(getOperation(new ConfigOperation(), Operation.Type.CONFIG, CONFIG_OPERATION_CODE), this.deviceIds); + validateOperationResponse(activity); } @Test(dependsOnMethods = "addConfigOperation") public void addProfileOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - this.operationMgtService.addOperation(getOperation(new ProfileOperation(), Operation.Type.PROFILE, PROFILE_OPERATION_CODE), + Activity activity = this.operationMgtService.addOperation(getOperation(new ProfileOperation(), Operation.Type.PROFILE, PROFILE_OPERATION_CODE), this.deviceIds); + validateOperationResponse(activity); } private Operation getOperation(Operation operation, Operation.Type type, String code) { @@ -137,11 +157,77 @@ public class OperationManagementTests extends BaseDeviceManagementTest { return operation; } + private void validateOperationResponse(Activity activity) { + Assert.assertEquals(activity.getActivityStatus().size(), NO_OF_DEVICES, "The operation reponse for add operation only have - " + + activity.getActivityStatus().size()); + for (ActivityStatus status : activity.getActivityStatus()) { + Assert.assertEquals(status.getStatus(), ActivityStatus.Status.PENDING); + } + } + @Test(dependsOnMethods = "addProfileOperation") - public void verifyCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + public void getOperations() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + for (DeviceIdentifier deviceIdentifier : deviceIds) { + List operations = this.operationMgtService.getOperations(deviceIdentifier); + Assert.assertEquals(operations.size(), 4, "The operations should be 4, but found only " + operations.size()); + } + } + + @Test(dependsOnMethods = "getOperations") + public void getPendingOperations() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { for (DeviceIdentifier deviceIdentifier : deviceIds) { List operations = this.operationMgtService.getPendingOperations(deviceIdentifier); Assert.assertEquals(operations.size(), 4, "The pending operations should be 4, but found only " + operations.size()); } } + + @Test(dependsOnMethods = "getPendingOperations") + public void getPaginatedRequestAsAdmin() throws OperationManagementException { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER); + PaginationRequest request = new PaginationRequest(1, 2); + request.setDeviceType(DEVICE_TYPE); + request.setOwner(ADMIN_USER); + for (DeviceIdentifier deviceIdentifier : deviceIds) { + PaginationResult result = this.operationMgtService.getOperations(deviceIdentifier, request); + Assert.assertEquals(result.getRecordsFiltered(), 4); + Assert.assertEquals(result.getData().size(), 2); + Assert.assertEquals(result.getRecordsTotal(), 4); + } + PrivilegedCarbonContext.endTenantFlow(); + } + + @Test(dependsOnMethods = "getPendingOperations") + public void getPaginatedRequestAsNonAdmin() throws OperationManagementException { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(NON_ADMIN_USER); + PaginationRequest request = new PaginationRequest(1, 2); + request.setDeviceType(DEVICE_TYPE); + request.setOwner(ADMIN_USER); + for (DeviceIdentifier deviceIdentifier : deviceIds) { + try { + this.operationMgtService.getOperations(deviceIdentifier, request); + } catch (OperationManagementException ex) { + if (ex.getMessage() == null){ + Assert.assertTrue(ex.getMessage().contains("User '" + NON_ADMIN_USER + "' is not authorized")); + } + } + } + PrivilegedCarbonContext.endTenantFlow(); + } + + @Test(dependsOnMethods = "getPaginatedRequestAsAdmin") + public void updateOperation() throws OperationManagementException { + DeviceIdentifier deviceIdentifier = this.deviceIds.get(0); + List operations = this.operationMgtService.getPendingOperations(deviceIdentifier); + Assert.assertTrue(operations!= null && operations.size()==4); + Operation operation = (Operation) operations.get(0); + operation.setStatus(Operation.Status.COMPLETED); + operation.setOperationResponse("The operation is successfully completed"); + this.operationMgtService.updateOperation(deviceIdentifier, operation); + List pendingOperations = this.operationMgtService.getPendingOperations(deviceIdentifier); + Assert.assertEquals(pendingOperations.size(), 3); + } } From f4700adc3b15e04ec53b30e4cd58d5cc00ac38af Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 26 Sep 2017 13:41:32 +0530 Subject: [PATCH 4/6] Fixing issues in the device management repository tests. --- .../mgt/core/DeviceManagementRepositoryTests.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index 925d8a9e8d..d1bf071f25 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -23,15 +23,22 @@ import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; import org.wso2.carbon.device.mgt.core.common.TestDataHolder; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; +import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; +import org.wso2.carbon.ntask.core.service.TaskService; +import org.wso2.carbon.ntask.core.service.impl.TaskServiceImpl; -public class DeviceManagementRepositoryTests { +public class DeviceManagementRepositoryTests extends BaseDeviceManagementTest{ private DeviceManagementPluginRepository repository; @BeforeClass - public void initRepository() { + @Override + public void init() throws Exception { this.repository = new DeviceManagementPluginRepository(); + DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(new DeviceTaskManagerServiceImpl()); } @Test From e6435653160d828d5317af0e0e5b04c6e624e2e6 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 26 Sep 2017 15:50:01 +0530 Subject: [PATCH 5/6] Fixing the test case failures. --- .../core/DeviceManagementRepositoryTests.java | 4 +- .../device/mgt/core/TestTaskServiceImpl.java | 123 ++++++++++++++++++ .../mgt/core/dao/GroupPersistTests.java | 60 +++++---- .../operation/OperationManagementTests.java | 5 +- .../DeviceManagementProviderServiceTest.java | 8 +- .../src/test/resources/testng.xml | 1 + 6 files changed, 164 insertions(+), 37 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestTaskServiceImpl.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index d1bf071f25..68678131f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -21,14 +21,11 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; -import org.wso2.carbon.ntask.core.service.TaskService; -import org.wso2.carbon.ntask.core.service.impl.TaskServiceImpl; public class DeviceManagementRepositoryTests extends BaseDeviceManagementTest{ @@ -39,6 +36,7 @@ public class DeviceManagementRepositoryTests extends BaseDeviceManagementTest{ public void init() throws Exception { this.repository = new DeviceManagementPluginRepository(); DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(new DeviceTaskManagerServiceImpl()); + DeviceManagementDataHolder.getInstance().setTaskService(new TestTaskServiceImpl()); } @Test diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestTaskServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestTaskServiceImpl.java new file mode 100644 index 0000000000..7210942ca5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestTaskServiceImpl.java @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.wso2.carbon.device.mgt.core; + +import org.wso2.carbon.ntask.common.TaskException; +import org.wso2.carbon.ntask.core.TaskInfo; +import org.wso2.carbon.ntask.core.TaskManager; +import org.wso2.carbon.ntask.core.service.TaskService; + +import java.util.List; +import java.util.Set; + +public class TestTaskServiceImpl implements TaskService { + @Override + public TaskManager getTaskManager(String s) throws TaskException { + return new TaskManager() { + @Override + public void initStartupTasks() throws TaskException { + + } + + @Override + public void scheduleTask(String s) throws TaskException { + + } + + @Override + public void rescheduleTask(String s) throws TaskException { + + } + + @Override + public boolean deleteTask(String s) throws TaskException { + return false; + } + + @Override + public void pauseTask(String s) throws TaskException { + + } + + @Override + public void resumeTask(String s) throws TaskException { + + } + + @Override + public void registerTask(TaskInfo taskInfo) throws TaskException { + + } + + @Override + public TaskState getTaskState(String s) throws TaskException { + return null; + } + + @Override + public TaskInfo getTask(String s) throws TaskException { + return null; + } + + @Override + public List getAllTasks() throws TaskException { + return null; + } + + @Override + public boolean isTaskScheduled(String s) throws TaskException { + return false; + } + }; + } + + @Override + public List getAllTenantTaskManagersForType(String s) throws TaskException { + return null; + } + + @Override + public void registerTaskType(String s) throws TaskException { + + } + + @Override + public Set getRegisteredTaskTypes() { + return null; + } + + @Override + public void serverInitialized() { + + } + + @Override + public boolean isServerInit() { + return false; + } + + @Override + public TaskServiceConfiguration getServerConfiguration() { + return null; + } + + @Override + public void runAfterRegistrationActions() throws TaskException { + + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/GroupPersistTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/GroupPersistTests.java index 1115faeab1..cc57e51b85 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/GroupPersistTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/GroupPersistTests.java @@ -25,6 +25,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.Device; 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.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; @@ -54,20 +55,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupId = groupDAO.addGroup(deviceGroup, TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); + GroupManagementDAOFactory.closeConnection(); log.debug("Group added to database. ID: " + groupId); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while adding device type '" + deviceGroup.getName() + "'."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } - DeviceGroup group = getGroupById(groupId); Assert.assertNotNull(group, "Group is null"); log.debug("Group name: " + group.getName()); @@ -81,19 +82,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest { request.setGroupName(null); request.setOwner(null); List groups = groupDAO.getGroups(request, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.closeConnection(); Assert.assertNotEquals(groups.size(), 0, "No groups found"); Assert.assertNotNull(groups.get(0), "Group is null"); log.debug("No of Groups found: " + groups.size()); } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while find group by name."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -109,18 +111,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { } GroupManagementDAOFactory.commitTransaction(); List roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.closeConnection(); Assert.assertEquals(roles, addedRoles, "Added roles are not equal to returned roles."); log.debug("Group shared with roles."); } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while find group by name."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -131,19 +134,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest { List roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID); roles.remove(0); List 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.get(0).getGroupId(), groupId, "Unexpected groupId found with role."); log.debug("Group found for given roles."); } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while getting groups shared with roles."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -157,18 +161,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { } GroupManagementDAOFactory.commitTransaction(); List roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.closeConnection(); Assert.assertNotEquals(roles, rolesToRemove, "Roles not removed."); log.debug("Group unshared with given roles."); } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while find group by name."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -181,36 +186,38 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.addDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); + GroupManagementDAOFactory.closeConnection(); log.debug("Device added to group."); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while adding device '" + initialTestDevice.getName() + "'."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } try { GroupManagementDAOFactory.openConnection(); List groupedDevices = groupDAO.getDevices(deviceGroup.getGroupId(), 0, 10, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.closeConnection(); Assert.assertNotEquals(groupedDevices.size(), 0, "No device found"); Assert.assertNotNull(groupedDevices.get(0), "Device is null"); Assert.assertEquals(groupedDevices.get(0).getId(), initialTestDevice.getId(), "Device ids not matched"); } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while retrieving group details."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -223,18 +230,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.removeDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); + GroupManagementDAOFactory.closeConnection(); log.debug("Device added to group."); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while adding device '" + initialTestDevice.getDeviceIdentifier() + "'."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } } @@ -250,18 +258,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.updateGroup(group, groupId, TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); + GroupManagementDAOFactory.closeConnection(); log.debug("Group updated"); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while updating group details."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } group = getGroupById(groupId); @@ -278,18 +287,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.deleteGroup(group.getGroupId(), TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); + GroupManagementDAOFactory.closeConnection(); log.debug("Group deleted"); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while updating group details."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } group = getGroupById(groupId); Assert.assertNull(group, "Group is not deleted"); @@ -298,17 +308,19 @@ public class GroupPersistTests extends BaseDeviceManagementTest { private DeviceGroup getGroupById(int groupId) { try { 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) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while retrieving group details."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { + GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); } return null; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java index f205725565..81cc2c4738 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/operation/OperationManagementTests.java @@ -64,7 +64,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -public class OperationManagementTests extends BaseDeviceManagementTest { +public class OperationManagementTests{ private static final Log log = LogFactory.getLog(OperationManagementTests.class); private static final String DEVICE_TYPE = "OP_TEST_TYPE"; @@ -82,10 +82,8 @@ public class OperationManagementTests extends BaseDeviceManagementTest { private OperationManager operationMgtService; @BeforeClass - @Override public void init() throws Exception { DeviceConfigurationManager.getInstance().initConfig(); - initDataSource(); log.info("Initializing"); for (int i = 0; i < NO_OF_DEVICES; i++) { deviceIds.add(new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE)); @@ -97,6 +95,7 @@ public class OperationManagementTests extends BaseDeviceManagementTest { DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService()); DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl()); DeviceManagementDataHolder.getInstance().setGroupManagementProviderService(new GroupManagementProviderServiceImpl()); + DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null); deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); for (Device device : devices) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java index d181c28dd0..a48ce1d3a7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; -public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTest { +public class DeviceManagementProviderServiceTest { private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceTest.class); private DeviceManagementProviderService providerService; @@ -34,9 +34,7 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes @BeforeClass - @Override public void init() throws Exception { - this.initDataSource(); this.providerService = new DeviceManagementProviderServiceImpl(); } @@ -82,8 +80,4 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes } } - @AfterClass - public void cleanResources() { - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index 7e7ae9512d..e562ed1740 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -40,6 +40,7 @@ + From ab1ef219ed7c172974822e8a1c5d563c4e6d070c Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 26 Sep 2017 15:53:16 +0530 Subject: [PATCH 6/6] Removing unnecessary extension. --- .../device/mgt/core/DeviceManagementRepositoryTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java index 68678131f3..cd39bd57b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java @@ -27,12 +27,11 @@ import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; -public class DeviceManagementRepositoryTests extends BaseDeviceManagementTest{ +public class DeviceManagementRepositoryTests{ private DeviceManagementPluginRepository repository; @BeforeClass - @Override public void init() throws Exception { this.repository = new DeviceManagementPluginRepository(); DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(new DeviceTaskManagerServiceImpl());