Refactoring

revert-70aa11f8
megala21 7 years ago
parent 6637c63c6b
commit eff3efb72c

@ -83,27 +83,19 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-dbcp.wso2</groupId> <groupId>commons-dbcp.wso2</groupId>
<artifactId>commons-dbcp</artifactId> <artifactId>commons-dbcp</artifactId>
<version>1.4.0.wso2v1</version> <scope>test</scope>
<scope>test</scope> </dependency>
<dependency>
<groupId>commons-pool.wso2</groupId>
<artifactId>commons-pool</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>commons-pool.wso2</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.6.wso2v1</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.governance</groupId> <groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.registry.extensions</artifactId> <artifactId>org.wso2.carbon.governance.registry.extensions</artifactId>
<version>4.7.8</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.registry</groupId> <groupId>org.wso2.carbon.registry</groupId>

@ -252,21 +252,24 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
} }
private void initializeDbQueries() { private void initializeDbQueries() {
selectDBQueryForGetDevice = "SELECT " + getDeviceTableColumnNames() + " FROM " + selectDBQueryForGetDevice =
deviceDAODefinition.getDeviceTableName() + " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?"; "SELECT " + getDeviceTableColumnNames() + " FROM " + deviceDAODefinition.getDeviceTableName()
+ " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?";
createDBqueryForAddDevice = "INSERT INTO " + deviceDAODefinition.getDeviceTableName() + "(" createDBqueryForAddDevice =
+ deviceDAODefinition.getPrimaryKey() + " , " + getDeviceTableColumnNames() + ") VALUES (" "INSERT INTO " + deviceDAODefinition.getDeviceTableName() + "(" + deviceDAODefinition.getPrimaryKey()
+ getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")"; + " , " + getDeviceTableColumnNames() + ") VALUES (" + getPreparedInputString(
deviceDAODefinition.getColumnNames().size() + 1) + ")";
updateDBQueryForUpdateDevice = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET " updateDBQueryForUpdateDevice = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET "
+ getDeviceTableColumnNamesForUpdateQuery() + " WHERE " + deviceDAODefinition.getPrimaryKey() + getDeviceTableColumnNamesForUpdateQuery() + " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?";
+ " = ?";
deleteDBQueryToRemoveDevicd = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() deleteDBQueryToRemoveDevicd =
+ " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?"; "DELETE FROM " + deviceDAODefinition.getDeviceTableName() + " WHERE " + deviceDAODefinition
.getPrimaryKey() + " = ?";
selectDBQueryToGetAllDevice = "SELECT " + getDeviceTableColumnNames() + "," + deviceDAODefinition.getPrimaryKey() + selectDBQueryToGetAllDevice =
" FROM " + deviceDAODefinition.getDeviceTableName(); "SELECT " + getDeviceTableColumnNames() + "," + deviceDAODefinition.getPrimaryKey() + " FROM "
+ deviceDAODefinition.getDeviceTableName();
} }
} }

@ -1,3 +1,21 @@
/*
* 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.extensions.device.type.template; package org.wso2.carbon.device.mgt.extensions.device.type.template;
import org.testng.Assert; import org.testng.Assert;
@ -72,8 +90,7 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
@Test(description = "This test case tests the enrollment of newly added device type") @Test(description = "This test case tests the enrollment of newly added device type")
public void testEnrollDevice() throws DeviceManagementException { public void testEnrollDevice() throws DeviceManagementException {
String deviceId = "testdevice1"; String deviceId = "testdevice1";
Device sampleDevice1 = new Device(deviceId, androidSenseDeviceType, "test", "testdevice", Device sampleDevice1 = new Device(deviceId, androidSenseDeviceType, "test", "testdevice", null, null, null);
null, null, null);
Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager().enrollDevice(sampleDevice1), Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager().enrollDevice(sampleDevice1),
"Enrollment of " + androidSenseDeviceType + " device failed"); "Enrollment of " + androidSenseDeviceType + " device failed");
Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager() Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager()
@ -83,10 +100,10 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
@Test(description = "This test case tests the populate device management service method") @Test(description = "This test case tests the populate device management service method")
public void testPopulateDeviceManagementService() { public void testPopulateDeviceManagementService() {
DeviceManagementService deviceManagementService = deviceTypeGeneratorService.populateDeviceManagementService DeviceManagementService deviceManagementService = deviceTypeGeneratorService
(sampleDeviceType, deviceTypeMetaDefinition); .populateDeviceManagementService(sampleDeviceType, deviceTypeMetaDefinition);
Assert.assertEquals(deviceManagementService.getType(), sampleDeviceType, "DeviceTypeGeneration for the " Assert.assertEquals(deviceManagementService.getType(), sampleDeviceType,
+ "sample device type failed"); "DeviceTypeGeneration for the " + "sample device type failed");
} }
/** /**
@ -113,8 +130,8 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
.getPushNotificationProvider(); .getPushNotificationProvider();
PushNotificationConfig pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(), PushNotificationConfig pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(),
pushNotificationProvider.isScheduled(), null); pushNotificationProvider.isScheduled(), null);
org.wso2.carbon.device.mgt.extensions.device.type.template.config.License license = androidSenseDeviceTypeConfiguration org.wso2.carbon.device.mgt.extensions.device.type.template.config.License license =
.getLicense(); androidSenseDeviceTypeConfiguration.getLicense();
License androidSenseLicense = new License(); License androidSenseLicense = new License();
androidSenseLicense.setText(license.getText()); androidSenseLicense.setText(license.getText());
androidSenseLicense.setLanguage(license.getLanguage()); androidSenseLicense.setLanguage(license.getLanguage());
@ -138,4 +155,3 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
deviceTypeMetaDefinition.setFeatures(features); deviceTypeMetaDefinition.setFeatures(features);
} }
} }

@ -151,7 +151,6 @@ public class Utils {
deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable); deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
} }
} }
} }
return deviceDAODefinition; return deviceDAODefinition;
} }

@ -22,29 +22,14 @@
<Feature code="keywords"> <Feature code="keywords">
<Name>Add Keywords</Name> <Name>Add Keywords</Name>
<Description>Send keywords to the device</Description> <Description>Send keywords to the device</Description>
<!--<Operation context="/android_sense/device/{deviceId}/words" method="POST">-->
<!--<QueryParameters>-->
<!--<Parameter>keywords</Parameter>-->
<!--</QueryParameters>-->
<!--</Operation>-->
</Feature> </Feature>
<Feature code="threshold"> <Feature code="threshold">
<Name>Add Threshold</Name> <Name>Add Threshold</Name>
<Description>Send Threshold to the device</Description> <Description>Send Threshold to the device</Description>
<!--<Operation context="/android_sense/device/{deviceId}/words/threshold" method="POST">-->
<!--<QueryParameters>-->
<!--<Parameter>threshold</Parameter>-->
<!--</QueryParameters>-->
<!--</Operation>-->
</Feature> </Feature>
<Feature code="remove_words"> <Feature code="remove_words">
<Name>Remove words</Name> <Name>Remove words</Name>
<Description>Remove Threshold from the device</Description> <Description>Remove Threshold from the device</Description>
<!--<Operation context="/android_sense/device/{deviceId}/words" method="DELETE">-->
<!--<QueryParameters>-->
<!--<Parameter>words</Parameter>-->
<!--</QueryParameters>-->
<!--</Operation>-->
</Feature> </Feature>
</Features> </Features>
@ -62,4 +47,4 @@
<Text>This is license text</Text> <Text>This is license text</Text>
</License> </License>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

@ -40,4 +40,4 @@
<Text>This is license text</Text> <Text>This is license text</Text>
</License> </License>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com) ~ Copyright 2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright 2005-2017 WSO2 Inc. (http://wso2.com) ~ Copyright 2017 WSO2 Inc. (http://wso2.com)
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.
@ -37,62 +37,6 @@
<minIdle>5</minIdle> <minIdle>5</minIdle>
</dbConfig> </dbConfig>
<!--<handler class="org.wso2.carbon.registry.extensions.handlers.SynapseRepositoryHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.apache.synapse</property>
</filter>
</handler>
<handler class="org.wso2.carbon.registry.extensions.handlers.SynapseRepositoryHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.apache.esb</property>
</filter>
</handler>
<handler class="org.wso2.carbon.registry.extensions.handlers.Axis2RepositoryHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.apache.axis2</property>
</filter>
</handler>
<handler class="org.wso2.carbon.registry.extensions.handlers.Axis2RepositoryHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.apache.wsas</property>
</filter>
</handler>
<handler class="org.wso2.carbon.registry.extensions.handlers.WSDLMediaTypeHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/wsdl+xml</property>
</filter>
</handler>
<handler class="org.wso2.carbon.registry.extensions.handlers.XSDMediaTypeHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/x-xsd+xml</property>
</filter>
</handler> -->
<!--remoteInstance url="https://localhost:9443/registry">
<id>instanceid</id>
<username>username</username>
<password>password</password>
</remoteInstance-->
<!--remoteInstance url="https://localhost:9443/registry">
<id>instanceid</id>
<dbConfig>wso2registry</dbConfig>
<readOnly>false</readOnly>
<enableCache>true</enableCache>
<registryRoot>/</registryRoot>
</remoteInstance-->
<!--mount path="/_system/config" overwrite="true|false|virtual">
<instanceId>instanceid</instanceId>
<targetPath>/_system/nodes</targetPath>
</mount-->
<versionResourcesOnChange>false</versionResourcesOnChange> <versionResourcesOnChange>false</versionResourcesOnChange>
<!-- NOTE: You can edit the options under "StaticConfiguration" only before the <!-- NOTE: You can edit the options under "StaticConfiguration" only before the

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except
@ -16,22 +16,22 @@
~ under the License. ~ under the License.
--> -->
<UserManager> <UserManager>
<Realm> <Realm>
<Configuration> <Configuration>
<AddAdmin>true</AddAdmin> <AddAdmin>true</AddAdmin>
<AdminRole>admin</AdminRole> <AdminRole>admin</AdminRole>
<AdminUser> <AdminUser>
<UserName>admin</UserName> <UserName>admin</UserName>
<Password>admin</Password> <Password>admin</Password>
</AdminUser> </AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName> <EveryOneRoleName>everyone</EveryOneRoleName>
<ReadOnly>false</ReadOnly> <ReadOnly>false</ReadOnly>
<MaxUserNameListLength>500</MaxUserNameListLength> <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="driverName">org.h2.Driver</Property>
<Property name="maxActive">50</Property> <Property name="maxActive">50</Property>
<Property name="maxWait">60000</Property> <Property name="maxWait">60000</Property>
<Property name="minIdle">5</Property> <Property name="minIdle">5</Property>
</Configuration> </Configuration>
<UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"> <UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property> <Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property>
@ -62,9 +62,9 @@
<Property name="BulkImportSupported">true</Property> <Property name="BulkImportSupported">true</Property>
</UserStoreManager> </UserStoreManager>
<AuthorizationManager <AuthorizationManager
class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager"> class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AuthorizationCacheEnabled">true</Property> <Property name="AuthorizationCacheEnabled">true</Property>
</AuthorizationManager> </AuthorizationManager>
</Realm> </Realm>
<SystemPermission> <SystemPermission>
<Permission>login</Permission> <Permission>login</Permission>

@ -1538,6 +1538,24 @@
<version>${power.mock.version}</version> <version>${power.mock.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>commons-dbcp.wso2</groupId>
<artifactId>commons-dbcp</artifactId>
<version>${commons.dbcp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.registry.extensions</artifactId>
<version>${carbon.governance.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -1968,6 +1986,8 @@
<jacoco.ant.verision>0.7.5.201505241946</jacoco.ant.verision> <jacoco.ant.verision>0.7.5.201505241946</jacoco.ant.verision>
<ant.contrib.version>1.0b3</ant.contrib.version> <ant.contrib.version>1.0b3</ant.contrib.version>
<power.mock.version>1.7.0</power.mock.version> <power.mock.version>1.7.0</power.mock.version>
<commons.dbcp.version>1.4.0.wso2v1</commons.dbcp.version>
</properties> </properties>
</project> </project>

Loading…
Cancel
Save