Refactoring

merge-requests/1/head
megala21 7 years ago
parent 845749df14
commit 4d1b9ea03d

@ -111,24 +111,24 @@ public class DeviceTypeManagerNegativeTest {
}
createDefectiveDeviceTypeManager();
deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId("test");
deviceIdentifier.setId(Utils.TEST_STRING);
deviceIdentifier.setType(ANDROID_DEVICE_TYPE);
DeviceDetails deviceDetails = new DeviceDetails();
Properties properties = new Properties();
List<String> propertyList = new ArrayList<>();
propertyList.add("test");
propertyList.add(Utils.TEST_STRING);
properties.addProperties(propertyList);
deviceDetails.setProperties(properties);
propertyBasedPluginDAO = new PropertyBasedPluginDAOImpl(deviceDetails,
deviceTypeDAOHandler, ANDROID_DEVICE_TYPE);
sampleDevice = new Device();
sampleDevice.setDeviceIdentifier("test");
sampleDevice.setDeviceIdentifier(Utils.TEST_STRING);
List<Device.Property> deviceProperties = new ArrayList<>();
Device.Property property = new Device.Property();
property.setName("test");
property.setValue("test");
property.setName(Utils.TEST_STRING);
property.setValue(Utils.TEST_STRING);
deviceProperties.add(property);
sampleDevice.setProperties(deviceProperties);
}

@ -170,8 +170,8 @@ public class DeviceTypeManagerTest {
Assert.assertTrue(customDeviceTypeManager.enrollDevice(customDevice), "Custom device type enrollment failed.");
List<Device.Property> properties = customDevice.getProperties();
Device.Property property = new Device.Property();
property.setName("test");
property.setValue("test");
property.setName(Utils.TEST_STRING);
property.setValue(Utils.TEST_STRING);
properties.add(property);
customDevice.setProperties(properties);
Assert.assertFalse(customDeviceTypeManager.enrollDevice(customDevice),
@ -239,8 +239,8 @@ public class DeviceTypeManagerTest {
list.add(property);
}
sampleDevice1 = new Device("testdevice", androidDeviceType, "test", "testdevice", null, null, list);
sampleDevice2 = new Device("testdevice1", androidDeviceType, "test", "testdevice", null, null, list);
sampleDevice1 = new Device("testdevice", androidDeviceType, Utils.TEST_STRING, "testdevice", null, null, list);
sampleDevice2 = new Device("testdevice1", androidDeviceType, Utils.TEST_STRING, "testdevice", null, null, list);
}
/**

@ -79,7 +79,8 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
@Test(description = "This test case tests the enrollment of newly added device type")
public void testEnrollDevice() throws DeviceManagementException {
String deviceId = "testdevice1";
Device sampleDevice1 = new Device(deviceId, androidSenseDeviceType, "test", "testdevice", null, null, null);
Device sampleDevice1 = new Device(deviceId, androidSenseDeviceType, Utils.TEST_STRING, "testdevice", null, null,
null);
Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager().enrollDevice(sampleDevice1),
"Enrollment of " + androidSenseDeviceType + " device failed");
Assert.assertTrue(httpDeviceTypeManagerService.getDeviceManager()
@ -112,7 +113,7 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
ConfigurationEntry configurationEntry = configurationEntries.get(0);
Assert.assertEquals(configurationEntry.getName(), "test",
Assert.assertEquals(configurationEntry.getName(), Utils.TEST_STRING,
"Platform Configuration for device type " + "sample is not saved correctly");
String contentType = configurationEntry.getContentType();
@ -154,10 +155,10 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
.getDeclaredMethod("getDeviceTypeConfiguration", String.class, DeviceTypeMetaDefinition.class);
getDeviceTypeConfiguration.setAccessible(true);
List<String> properties = new ArrayList<>();
properties.add("test");
properties.add(Utils.TEST_STRING);
deviceTypeMetaDefinition.setProperties(properties);
Map<String, String> mapProperties = new HashMap<>();
mapProperties.put("test", "test");
mapProperties.put(Utils.TEST_STRING, Utils.TEST_STRING);
PushNotificationConfig pushNotificationConfig = new PushNotificationConfig("push", true, mapProperties);
deviceTypeMetaDefinition.setPushNotificationConfig(pushNotificationConfig);
DeviceTypeConfiguration deviceTypeConfiguration = (DeviceTypeConfiguration) getDeviceTypeConfiguration
@ -209,7 +210,7 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
org.wso2.carbon.device.mgt.common.Feature.MetadataEntry metadataEntry = new org.wso2.carbon.device.mgt
.common.Feature.MetadataEntry();
metadataEntry.setId(1);
metadataEntry.setValue("test");
metadataEntry.setValue(Utils.TEST_STRING);
List<org.wso2.carbon.device.mgt.common.Feature.MetadataEntry> metadataEntries = new ArrayList<>();
metadataEntries.add(metadataEntry);
commonFeature.setMetadataEntries(metadataEntries);

@ -56,6 +56,7 @@ import java.util.List;
*/
public class Utils {
public static final String DEVICE_TYPE_FOLDER = "device-types" + File.separator;
public static final String TEST_STRING = "test";
/**
* To get the device type configuration based on the configuration file

@ -68,7 +68,7 @@ public class UtilsTest {
@Test(description = "This test case tests the getLicense method of the FileBasedLicenseManager")
public void testFileBasedLicenseManagerGetLicense() throws LicenseManagementException {
License fileBasedLicense = fileSystemBasedLicenseManager.getLicense("test","en_US");
License fileBasedLicense = fileSystemBasedLicenseManager.getLicense(Utils.TEST_STRING,"en_US");
Assert.assertEquals(fileBasedLicense.getText(), "This is a file based license",
"FileBased License cannot " + "be retrieved by FileBasedLicenseManager");
}
@ -84,7 +84,7 @@ public class UtilsTest {
+ "file system", expectedExceptions = {UnsupportedOperationException.class},
expectedExceptionsMessageRegExp = "'addLicense' method is not supported in FileSystemBasedLicenseManager")
public void testFileBasedLicenseManagerAddLicense() throws LicenseManagementException {
fileSystemBasedLicenseManager.addLicense("test", null);
fileSystemBasedLicenseManager.addLicense(Utils.TEST_STRING, null);
}
@Test(description = "This test case tests the DeviceTypeConfigIdentifier equals method")
@ -102,15 +102,16 @@ public class UtilsTest {
@Test(description = "This test cases tests the registry based license addition")
public void testAddRegistryBasedLicense() throws LicenseManagementException {
String newLicenseString = "New License";
License fileBasedLicense = fileSystemBasedLicenseManager.getLicense("test", "en_US");
License fileBasedLicense = fileSystemBasedLicenseManager.getLicense(Utils.TEST_STRING, "en_US");
RegistryBasedLicenseManager registryBasedLicenseManager = new RegistryBasedLicenseManager();
registryBasedLicenseManager.addLicense("test", fileBasedLicense);
registryBasedLicenseManager.addLicense(Utils.TEST_STRING, fileBasedLicense);
Assert.assertEquals(fileBasedLicense.getText(),
registryBasedLicenseManager.getLicense("test", "en_US").getText(), "Registry license addition failed");
registryBasedLicenseManager.getLicense(Utils.TEST_STRING, "en_US").getText(),
"Registry license addition failed");
fileBasedLicense.setText(newLicenseString);
registryBasedLicenseManager.addLicense("test", fileBasedLicense);
Assert.assertEquals(registryBasedLicenseManager.getLicense("test", "en_US").getText(), newLicenseString,
"Registry license update failed");
registryBasedLicenseManager.addLicense(Utils.TEST_STRING, fileBasedLicense);
Assert.assertEquals(registryBasedLicenseManager.getLicense(Utils.TEST_STRING, "en_US").getText(),
newLicenseString, "Registry license update failed");
}
@Test(description = "This test case tests the GetConfigurationRegistry method when the registry service is "

Loading…
Cancel
Save