mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request 'Fix test cases failing issue' (#183) from tcdlpds/device-mgt-core:sync-master into apim420
Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/183
This commit is contained in:
commit
d021b43086
@ -44,6 +44,11 @@
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<EveryOneRoleName>everyone</EveryOneRoleName>
|
||||
<ReadOnly>false</ReadOnly>
|
||||
<MaxUserNameListLength>500</MaxUserNameListLength>
|
||||
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="url">jdbc:h2:./target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="driverName">org.h2.Driver</Property>
|
||||
<Property name="maxActive">50</Property>
|
||||
<Property name="maxWait">60000</Property>
|
||||
|
||||
@ -16,24 +16,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.
|
||||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK (
|
||||
REG_LOCK_NAME VARCHAR (20),
|
||||
REG_LOCK_STATUS VARCHAR (20),
|
||||
@ -104,7 +86,6 @@ CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_
|
||||
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),
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<DataSourceConfig>
|
||||
<Url>jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true</Url>
|
||||
<Url>jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE</Url>
|
||||
<DriverClassName>org.h2.Driver</DriverClassName>
|
||||
<User>wso2carbon</User>
|
||||
<Password>wso2carbon</Password>
|
||||
|
||||
@ -38,6 +38,10 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -151,16 +155,25 @@
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-bundle-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
@ -179,6 +192,10 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.ops4j.pax.logging</groupId>
|
||||
<artifactId>pax-logging-log4j2</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -213,6 +230,14 @@
|
||||
<groupId>javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -295,6 +320,10 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -329,6 +358,12 @@
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.registry</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.resource</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -43,10 +43,11 @@ import java.util.List;
|
||||
/**
|
||||
* This is a test class for {@link ConfigurationServiceImpl}.
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.CarbonContext"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, PolicyManagerUtil.class})
|
||||
//@PowerMockIgnore("org.mockito.*")
|
||||
public class ConfigurationServiceImplTest {
|
||||
private ConfigurationManagementService configurationManagementService;
|
||||
private PlatformConfigurationManagementService platformConfigurationManagementService;
|
||||
|
||||
@ -69,7 +69,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This class holds the unit tests for the class {@link DeviceAgentServiceImpl}
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.context.internal.CarbonContextDataHolder"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class,
|
||||
|
||||
@ -72,7 +72,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This class includes unit tests for testing the functionality of {@link DeviceManagementServiceImpl}
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.user.core.service.RealmService"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class, RealmService.class})
|
||||
|
||||
@ -51,7 +51,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This class holds the unit tests for the class {@link DeviceTypeManagementAdminService}
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.PrivilegedCarbonContext"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class, CarbonContext.class})
|
||||
|
||||
@ -48,7 +48,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This class holds the unit tests for the class {@link DeviceTypeManagementService}
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class})
|
||||
public class DeviceTypeManagementServiceTest {
|
||||
@ -129,8 +129,9 @@ public class DeviceTypeManagementServiceTest {
|
||||
FeatureManager featureManager = Mockito.mock(FeatureManager.class);
|
||||
Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())).thenReturn
|
||||
(featureManager);
|
||||
Mockito.when((featureManager).getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException());
|
||||
Mockito.when((featureManager).getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException());
|
||||
Mockito.when(featureManager.getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException());
|
||||
Mockito.when(featureManager.getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException());
|
||||
Mockito.when(featureManager.getFeatures(Mockito.any(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException());
|
||||
Response response = this.deviceTypeManagementService.getFeatures(TEST_DEVICE_TYPE, null, "false", MODIFIED_SINCE);
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
||||
|
||||
@ -51,7 +51,7 @@ import java.util.List;
|
||||
/**
|
||||
* This is a test case for {@link GroupManagementServiceImpl}.
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.PrivilegedCarbonContext"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, CarbonContext.class})
|
||||
@ -125,13 +125,13 @@ public class GroupManagementServiceImplTest {
|
||||
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
|
||||
.toReturn(context);
|
||||
Mockito.doReturn(2).when(groupManagementProviderService)
|
||||
.getGroupCount(Mockito.anyString(), Mockito.anyString());
|
||||
.getGroupCount(Mockito.anyString(), Mockito.any());
|
||||
Response response = groupManagementService.getGroupCount();
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
||||
"GetGroupCount request failed with valid parameters");
|
||||
Mockito.reset(groupManagementProviderService);
|
||||
Mockito.doThrow(new GroupManagementException()).when(groupManagementProviderService)
|
||||
.getGroupCount(Mockito.anyString(), Mockito.anyString());
|
||||
.getGroupCount(Mockito.anyString(), Mockito.any());
|
||||
response = groupManagementService.getGroupCount();
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
||||
"GetGroupCount request succeeded with in-valid parameters");
|
||||
|
||||
@ -46,7 +46,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This is a test class for {@link NotificationManagementServiceImpl}.
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.CarbonContext"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class})
|
||||
|
||||
@ -61,7 +61,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
/**
|
||||
* This is a test case for {@link UserManagementService}.
|
||||
*/
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"})
|
||||
@SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils",
|
||||
"org.wso2.carbon.context.CarbonContext"})
|
||||
@PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class})
|
||||
|
||||
@ -514,7 +514,16 @@
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionMana
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.testng.Assert;
|
||||
import org.testng.IObjectFactory;
|
||||
@ -40,6 +41,9 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
* This contains unit tests for PermissionManagerService class.
|
||||
*/
|
||||
@PrepareForTest(PermissionUtils.class)
|
||||
@PowerMockIgnore("org.mockito.*")
|
||||
|
||||
//@PowerMockIgnore({"javax.management.*", "javax.script.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
|
||||
public class PermissionManagerServiceTest {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PermissionManagerServiceTest.class);;
|
||||
|
||||
@ -29,7 +29,6 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServic
|
||||
import io.entgra.device.mgt.core.device.mgt.core.search.mgt.InvalidOperatorException;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.ProcessorImpl;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.search.util.ChangeEnumValues;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.search.util.Utils;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||
@ -131,8 +130,6 @@ public class ProcessorImplTest extends BaseDeviceManagementTest {
|
||||
public void testInvalidState() throws SearchMgtException {
|
||||
SearchContext context = new SearchContext();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
ChangeEnumValues.addEnum(Condition.State.class, "BLA");
|
||||
Condition.State state = Condition.State.valueOf("BLA");
|
||||
|
||||
Condition cond = new Condition();
|
||||
cond.setKey("batteryLevel");
|
||||
@ -152,7 +149,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest {
|
||||
cond3.setKey("batteryLevel");
|
||||
cond3.setOperator("=");
|
||||
cond3.setValue("23.0");
|
||||
cond3.setState(state);
|
||||
cond3.setState(Condition.State.AND);
|
||||
conditions.add(cond3);
|
||||
|
||||
context.setConditions(conditions);
|
||||
|
||||
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.device.mgt.core.search.util;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.common.search.Condition;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Changes the Enum values of a given class.
|
||||
*/
|
||||
public class ChangeEnumValues {
|
||||
|
||||
private static ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
|
||||
|
||||
public ChangeEnumValues() {}
|
||||
|
||||
private static void setFailSafeFieldValue(Field field, Object target, Object value) throws NoSuchFieldException,
|
||||
IllegalAccessException {
|
||||
field.setAccessible(true);
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
int modifiers = modifiersField.getInt(field);
|
||||
modifiers &= ~Modifier.FINAL;
|
||||
modifiersField.setInt(field, modifiers);
|
||||
FieldAccessor fa = reflectionFactory.newFieldAccessor(field, false);
|
||||
fa.set(target, value);
|
||||
}
|
||||
|
||||
private static void blankField(Class<?> enumClass, String fieldName) throws NoSuchFieldException,
|
||||
IllegalAccessException {
|
||||
for (Field field : Class.class.getDeclaredFields()) {
|
||||
if (field.getName().contains(fieldName)) {
|
||||
AccessibleObject.setAccessible(new Field[]{field}, true);
|
||||
setFailSafeFieldValue(field, enumClass, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void cleanEnumCache(Class<?> enumClass) throws NoSuchFieldException, IllegalAccessException {
|
||||
blankField(enumClass, "enumConstantDirectory");
|
||||
blankField(enumClass, "enumConstants");
|
||||
}
|
||||
|
||||
private static ConstructorAccessor getConstructorAccessor(Class<?> enumClass, Class<?>[] additionalParameterTypes)
|
||||
throws NoSuchMethodException {
|
||||
Class<?>[] parameterTypes = new Class[additionalParameterTypes.length + 2];
|
||||
parameterTypes[0] = String.class;
|
||||
parameterTypes[1] = int.class;
|
||||
System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length);
|
||||
return reflectionFactory.newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes));
|
||||
}
|
||||
|
||||
private static Object makeEnum(Class<?> enumClass, String value, int ordinal, Class<?>[] additionalTypes,
|
||||
Object[] additionalValues) throws Exception {
|
||||
Object[] parms = new Object[additionalValues.length + 2];
|
||||
parms[0] = value;
|
||||
parms[1] = ordinal;
|
||||
System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length);
|
||||
return enumClass.cast(getConstructorAccessor(enumClass, additionalTypes).newInstance(parms));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an enum instance to the enum class given as argument
|
||||
*
|
||||
* @param <T> the type of the enum
|
||||
* @param enumType the class of the enum to be modified
|
||||
* @param enumName the name of the new enum instance to be added to the class.
|
||||
*/
|
||||
public static <T extends Enum<?>> void addEnum(Class<T> enumType, String enumName) {
|
||||
|
||||
if (!Enum.class.isAssignableFrom(enumType)) {
|
||||
throw new RuntimeException("class " + enumType + " is not an instance of Enum");
|
||||
}
|
||||
|
||||
Field valuesField = null;
|
||||
Field[] fields = Condition.State.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getName().contains("$VALUES")) {
|
||||
valuesField = field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AccessibleObject.setAccessible(new Field[]{valuesField}, true);
|
||||
|
||||
try {
|
||||
T[] previousValues = (T[]) valuesField.get(enumType);
|
||||
List<T> values = new ArrayList<T>(Arrays.asList(previousValues));
|
||||
T newValue = (T) makeEnum(enumType, enumName, values.size(), new Class<?>[]{}, new Object[]{});
|
||||
values.add(newValue);
|
||||
setFailSafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0)));
|
||||
cleanEnumCache(enumType);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<DataSourceConfig>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true</Url>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE</Url>
|
||||
<DriverClassName>io.entgra.device.mgt.core.device.mgt.core.mock.MockJDBCDriver</DriverClassName>
|
||||
<User>wso2carbon</User>
|
||||
<Password>wso2carbon</Password>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<DataSourceConfig>
|
||||
<Url>jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true</Url>
|
||||
<Url>jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE</Url>
|
||||
<DriverClassName>org.h2.Driver</DriverClassName>
|
||||
<User>wso2carbon</User>
|
||||
<Password>wso2carbon</Password>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<DataSourceConfig>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true</Url>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE</Url>
|
||||
<DriverClassName>org.h2.Driver</DriverClassName>
|
||||
<User>wso2carbon</User>
|
||||
<Password>wso2carbon</Password>
|
||||
|
||||
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE (
|
||||
ID INTEGER auto_increment NOT NULL,
|
||||
DESCRIPTION TEXT DEFAULT NULL,
|
||||
NAME VARCHAR(100) DEFAULT NULL,
|
||||
DEVICE_TYPE_ID INT(11) DEFAULT NULL,
|
||||
DEVICE_TYPE_ID INT DEFAULT NULL,
|
||||
DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
@ -180,16 +180,18 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
NAME VARCHAR(45) DEFAULT NULL ,
|
||||
DESCRIPTION VARCHAR(1000) NULL,
|
||||
TENANT_ID INT(11) NOT NULL ,
|
||||
PROFILE_ID INT(11) NOT NULL ,
|
||||
PAYLOAD_VERSION VARCHAR (45) NULL,
|
||||
TENANT_ID INT NOT NULL ,
|
||||
PROFILE_ID INT NOT NULL ,
|
||||
OWNERSHIP_TYPE VARCHAR(45) NULL,
|
||||
COMPLIANCE VARCHAR(100) NULL,
|
||||
PRIORITY INT NOT NULL,
|
||||
ACTIVE INT(2) NOT NULL,
|
||||
UPDATED INT(1) NULL,
|
||||
ACTIVE INT NOT NULL,
|
||||
UPDATED INT NULL,
|
||||
POLICY_TYPE VARCHAR(45) NULL,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_DM_PROFILE_DM_POLICY
|
||||
FOREIGN KEY (PROFILE_ID )
|
||||
@ -199,11 +201,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
DEVICE_ID INT(11) NOT NULL ,
|
||||
ENROLMENT_ID INT(11) NOT NULL,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
DEVICE_ID INT NOT NULL ,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
DEVICE BLOB NOT NULL,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_POLICY_DEVICE_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -218,9 +220,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
||||
ID INT(11) NOT NULL ,
|
||||
ID INT NOT NULL ,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL ,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_DEVICE_TYPE_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -230,11 +232,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||
PROFILE_ID INT(11) NOT NULL,
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
PROFILE_ID INT NOT NULL,
|
||||
FEATURE_CODE VARCHAR(100) NOT NULL,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL,
|
||||
TENANT_ID INT(11) NOT NULL ,
|
||||
TENANT_ID INT NOT NULL ,
|
||||
CONTENT BLOB NULL DEFAULT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
|
||||
@ -245,9 +247,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
ROLE_NAME VARCHAR(45) NOT NULL ,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_ROLE_POLICY_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -271,11 +273,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
|
||||
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,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
POLICY_CONTENT BLOB NULL ,
|
||||
TENANT_ID INT NOT NULL,
|
||||
APPLIED TINYINT(1) NULL ,
|
||||
APPLIED TINYINT NULL ,
|
||||
CREATED_TIME TIMESTAMP NULL ,
|
||||
UPDATED_TIME TIMESTAMP NULL ,
|
||||
APPLIED_TIME TIMESTAMP NULL ,
|
||||
@ -328,7 +330,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
|
||||
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
DEVICE_ID INT NOT NULL,
|
||||
ENROLMENT_ID INT(11) NOT NULL,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
POLICY_ID INT NOT NULL,
|
||||
TENANT_ID INT NOT NULL,
|
||||
STATUS INT NULL,
|
||||
@ -343,7 +345,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
POLICY_ID INT NOT NULL,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL ,
|
||||
TENANT_ID INT(11) NOT NULL,
|
||||
TENANT_ID INT NOT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
@ -372,7 +374,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
||||
LOCATION_URL VARCHAR(100) DEFAULT NULL,
|
||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||
APP_PROPERTIES BLOB NULL,
|
||||
MEMORY_USAGE INTEGER(10) NULL,
|
||||
MEMORY_USAGE INTEGER NULL,
|
||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
DEVICE_ID INTEGER NOT NULL,
|
||||
ENROLMENT_ID INTEGER NOT NULL,
|
||||
@ -439,7 +441,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||
STATE VARCHAR(45) NULL,
|
||||
COUNTRY VARCHAR(45) NULL,
|
||||
GEO_HASH VARCHAR(45) NULL,
|
||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||
FOREIGN KEY (DEVICE_ID)
|
||||
@ -472,8 +474,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||
CPU_USAGE DECIMAL(5) NULL,
|
||||
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
|
||||
AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL,
|
||||
PLUGGED_IN INT(1) NULL,
|
||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||
PLUGGED_IN INT NULL,
|
||||
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
||||
FOREIGN KEY (DEVICE_ID)
|
||||
@ -487,24 +489,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.
|
||||
*/
|
||||
|
||||
-- POLICY AND DEVICE GROUP MAPPING --
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<EveryOneRoleName>everyone</EveryOneRoleName>
|
||||
<ReadOnly>false</ReadOnly>
|
||||
<MaxUserNameListLength>500</MaxUserNameListLength>
|
||||
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="url">jdbc:h2:./target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="driverName">org.h2.Driver</Property>
|
||||
<Property name="maxActive">50</Property>
|
||||
<Property name="maxWait">60000</Property>
|
||||
|
||||
@ -66,6 +66,12 @@
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.platform</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
@ -111,10 +117,10 @@
|
||||
<artifactId>org.wso2.carbon.governance.registry.extensions</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -145,6 +151,11 @@
|
||||
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.notification.logger</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -263,8 +274,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@ -16,24 +16,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.
|
||||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK (
|
||||
REG_LOCK_NAME VARCHAR (20),
|
||||
REG_LOCK_STATUS VARCHAR (20),
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<DataSourceConfig>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true</Url>
|
||||
<Url>jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE</Url>
|
||||
<DriverClassName>org.h2.Driver</DriverClassName>
|
||||
<User>wso2carbon</User>
|
||||
<Password>wso2carbon</Password>
|
||||
|
||||
@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE (
|
||||
ID INTEGER auto_increment NOT NULL,
|
||||
DESCRIPTION TEXT DEFAULT NULL,
|
||||
NAME VARCHAR(100) DEFAULT NULL,
|
||||
DEVICE_TYPE_ID INT(11) DEFAULT NULL,
|
||||
DEVICE_TYPE_ID INT DEFAULT NULL,
|
||||
DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
@ -177,16 +177,16 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
NAME VARCHAR(45) DEFAULT NULL ,
|
||||
DESCRIPTION VARCHAR(1000) NULL,
|
||||
TENANT_ID INT(11) NOT NULL ,
|
||||
PROFILE_ID INT(11) NOT NULL ,
|
||||
TENANT_ID INT NOT NULL ,
|
||||
PROFILE_ID INT NOT NULL ,
|
||||
OWNERSHIP_TYPE VARCHAR(45) NULL,
|
||||
COMPLIANCE VARCHAR(100) NULL,
|
||||
PRIORITY INT NOT NULL,
|
||||
ACTIVE INT(2) NOT NULL,
|
||||
UPDATED INT(1) NULL,
|
||||
ACTIVE INT NOT NULL,
|
||||
UPDATED INT NULL,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_DM_PROFILE_DM_POLICY
|
||||
FOREIGN KEY (PROFILE_ID )
|
||||
@ -196,11 +196,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
DEVICE_ID INT(11) NOT NULL ,
|
||||
ENROLMENT_ID INT(11) NOT NULL,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
DEVICE_ID INT NOT NULL ,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
DEVICE BLOB NOT NULL,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_POLICY_DEVICE_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -215,9 +215,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
||||
ID INT(11) NOT NULL ,
|
||||
ID INT NOT NULL ,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL ,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_DEVICE_TYPE_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -227,11 +227,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||
PROFILE_ID INT(11) NOT NULL,
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
PROFILE_ID INT NOT NULL,
|
||||
FEATURE_CODE VARCHAR(100) NOT NULL,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL,
|
||||
TENANT_ID INT(11) NOT NULL ,
|
||||
TENANT_ID INT NOT NULL ,
|
||||
CONTENT BLOB NULL DEFAULT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
|
||||
@ -242,9 +242,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
||||
ID INT NOT NULL AUTO_INCREMENT ,
|
||||
ROLE_NAME VARCHAR(45) NOT NULL ,
|
||||
POLICY_ID INT(11) NOT NULL ,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
PRIMARY KEY (ID) ,
|
||||
CONSTRAINT FK_ROLE_POLICY_POLICY
|
||||
FOREIGN KEY (POLICY_ID )
|
||||
@ -268,11 +268,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
|
||||
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,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
POLICY_ID INT NOT NULL ,
|
||||
POLICY_CONTENT BLOB NULL ,
|
||||
TENANT_ID INT NOT NULL,
|
||||
APPLIED TINYINT(1) NULL ,
|
||||
APPLIED TINYINT NULL ,
|
||||
CREATED_TIME TIMESTAMP NULL ,
|
||||
UPDATED_TIME TIMESTAMP NULL ,
|
||||
APPLIED_TIME TIMESTAMP NULL ,
|
||||
@ -325,7 +325,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
|
||||
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
DEVICE_ID INT NOT NULL,
|
||||
ENROLMENT_ID INT(11) NOT NULL,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
POLICY_ID INT NOT NULL,
|
||||
TENANT_ID INT NOT NULL,
|
||||
STATUS INT NULL,
|
||||
@ -340,7 +340,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
POLICY_ID INT NOT NULL,
|
||||
DEVICE_TYPE VARCHAR(300) NOT NULL ,
|
||||
TENANT_ID INT(11) NOT NULL,
|
||||
TENANT_ID INT NOT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
@ -369,10 +369,22 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
||||
LOCATION_URL VARCHAR(100) DEFAULT NULL,
|
||||
IMAGE_URL VARCHAR(100) DEFAULT NULL,
|
||||
APP_PROPERTIES BLOB NULL,
|
||||
MEMORY_USAGE INTEGER(10) NULL,
|
||||
MEMORY_USAGE INTEGER NULL,
|
||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
DEVICE_ID INTEGER NOT NULL,
|
||||
ENROLMENT_ID INTEGER NOT NULL,
|
||||
TENANT_ID INTEGER NOT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT fk_dm_device
|
||||
FOREIGN KEY (DEVICE_ID)
|
||||
REFERENCES DM_DEVICE (ID)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT fk_dm_enrolement
|
||||
FOREIGN KEY (ENROLMENT_ID)
|
||||
REFERENCES DM_ENROLMENT (ID)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||
@ -380,34 +392,15 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||
DEVICE_ID INTEGER NOT NULL,
|
||||
APPLICATION_ID INTEGER NOT NULL,
|
||||
APP_PROPERTIES BLOB NULL,
|
||||
MEMORY_USAGE INTEGER(10) NULL,
|
||||
MEMORY_USAGE INTEGER NULL,
|
||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
TENANT_ID INTEGER NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||
CONSTRAINT fk_dm_device_tb FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.
|
||||
*/
|
||||
|
||||
-- POLICY RELATED TABLES FINISHED --
|
||||
|
||||
-- NOTIFICATION TABLE --
|
||||
@ -451,7 +444,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||
STATE VARCHAR(45) NULL,
|
||||
COUNTRY VARCHAR(45) NULL,
|
||||
GEO_HASH VARCHAR(45) NULL,
|
||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||
FOREIGN KEY (DEVICE_ID)
|
||||
@ -463,6 +456,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
DEVICE_ID INT NOT NULL,
|
||||
ENROLMENT_ID INT NOT NULL,
|
||||
DEVICE_MODEL VARCHAR(45) NULL,
|
||||
VENDOR VARCHAR(45) NULL,
|
||||
OS_VERSION VARCHAR(45) NULL,
|
||||
@ -477,13 +471,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||
CPU_USAGE DECIMAL(5) NULL,
|
||||
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
|
||||
AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL,
|
||||
PLUGGED_IN INT(1) NULL,
|
||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||
PLUGGED_IN INT NULL,
|
||||
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
||||
FOREIGN KEY (DEVICE_ID)
|
||||
REFERENCES DM_DEVICE (ID)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||
FOREIGN KEY (ENROLMENT_ID)
|
||||
REFERENCES DM_ENROLMENT (ID)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<EveryOneRoleName>everyone</EveryOneRoleName>
|
||||
<ReadOnly>false</ReadOnly>
|
||||
<MaxUserNameListLength>500</MaxUserNameListLength>
|
||||
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="url">jdbc:h2:./target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="driverName">org.h2.Driver</Property>
|
||||
<Property name="maxActive">50</Property>
|
||||
<Property name="maxWait">60000</Property>
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
<groupId>org.ops4j.pax.logging</groupId>
|
||||
<artifactId>pax-logging-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
<!-- <version>${pax.logging.api.version}</version>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
|
||||
@ -126,9 +126,6 @@
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
<classpathDependencyExcludes>
|
||||
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
|
||||
</classpathDependencyExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -286,6 +283,7 @@
|
||||
<dependency>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.notification.logger</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -642,8 +642,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
|
||||
@Override
|
||||
public void activatePolicy(int policyId) throws PolicyManagementException {
|
||||
Policy policy = this.getPolicy(policyId);
|
||||
try {
|
||||
Policy policy = this.getPolicy(policyId);
|
||||
PolicyManagementDAOFactory.beginTransaction();
|
||||
policyDAO.activatePolicy(policyId);
|
||||
policyDAO.recordUpdatedPolicy(policy);
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<EveryOneRoleName>everyone</EveryOneRoleName>
|
||||
<ReadOnly>false</ReadOnly>
|
||||
<MaxUserNameListLength>500</MaxUserNameListLength>
|
||||
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="url">jdbc:h2:./target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="driverName">org.h2.Driver</Property>
|
||||
<Property name="maxActive">50</Property>
|
||||
<Property name="maxWait">60000</Property>
|
||||
|
||||
12
pom.xml
12
pom.xml
@ -843,7 +843,6 @@
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis2.transport</groupId>
|
||||
<artifactId>axis2-transport-mail</artifactId>
|
||||
@ -1903,7 +1902,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<version>3.1.2</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jacoco-agent.destfile>${basedir}/target/coverage-reports/jacoco-ut.exec
|
||||
@ -2084,7 +2083,7 @@
|
||||
<nimbus.orbit.version.range>[7.3, 8)</nimbus.orbit.version.range>
|
||||
|
||||
<!--javax ws rs version-->
|
||||
<javax.ws.rs.version>2.0.1</javax.ws.rs.version>
|
||||
<javax.ws.rs.version>2.1.1</javax.ws.rs.version>
|
||||
<swagger.version>1.6.9</swagger.version>
|
||||
<swagger.annotations.version>1.6.9</swagger.annotations.version>
|
||||
<servlet-api.version>4.0.1</servlet-api.version>
|
||||
@ -2096,7 +2095,7 @@
|
||||
<joda-time.version>2.8.2.wso2v1</joda-time.version>
|
||||
<owasp.encoder.version>1.2.0.wso2v1</owasp.encoder.version>
|
||||
|
||||
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.1.2.Final</hibernate-validator.version>
|
||||
<javax.xml.parsers.import.pkg.version>[0.0.0,1.0.0)</javax.xml.parsers.import.pkg.version>
|
||||
<javax.xml.bind.imp.pkg.version>[0.0.0,1.0.0)</javax.xml.bind.imp.pkg.version>
|
||||
|
||||
@ -2125,8 +2124,7 @@
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
|
||||
<!-- jacoco plugin version -->
|
||||
<jacoco.maven.plugin.version>0.7.8</jacoco.maven.plugin.version>
|
||||
<jacoco.ant.verision>0.7.5.201505241946</jacoco.ant.verision>
|
||||
<jacoco.maven.plugin.version>0.8.10</jacoco.maven.plugin.version>
|
||||
<ant.contrib.version>1.0b3</ant.contrib.version>
|
||||
<power.mock.version>2.0.2</power.mock.version>
|
||||
<commons.dbcp.version>1.4.0.wso2v1</commons.dbcp.version>
|
||||
@ -2135,8 +2133,6 @@
|
||||
<!-- app management related versions -->
|
||||
<googlecode.plist.version>1.21</googlecode.plist.version>
|
||||
<net.dongliu.version>2.6.5</net.dongliu.version>
|
||||
<frontend.mave.version>1.7.6</frontend.mave.version>
|
||||
<node.version>v12.18.1</node.version>
|
||||
|
||||
<maven.checkstyle.vesion>3.1.0</maven.checkstyle.vesion>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user