use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device in project open-smart-grid-platform by OSGP.
the class CreateDeviceSteps method createDevice.
private Device createDevice(final Map<String, String> settings) {
final Device device = new Device();
device.setAlias(getString(settings, PlatformKeys.ALIAS, PlatformCommonDefaults.DEFAULT_ALIAS));
device.setContainerAddress(new AddressBuilder().withSettings(settings).build());
device.setDeviceIdentification(getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION));
final DeviceModel deviceModel = new DeviceModel();
deviceModel.setManufacturer(getString(settings, PlatformKeys.KEY_DEVICE_MODEL_MANUFACTURER, PlatformCommonDefaults.DEFAULT_DEVICE_MODEL_MANUFACTURER));
deviceModel.setModelCode(getString(settings, PlatformKeys.KEY_DEVICE_MODEL_MODELCODE, PlatformCommonDefaults.DEFAULT_DEVICE_MODEL_MODEL_CODE));
device.setDeviceModel(deviceModel);
device.setDeviceUid(getString(settings, PlatformKeys.KEY_DEVICE_UID, PlatformCommonDefaults.DEVICE_UID));
device.setGpsLatitude(getFloat(settings, PlatformKeys.KEY_LATITUDE, PlatformCommonDefaults.DEFAULT_LATITUDE));
device.setGpsLongitude(getFloat(settings, PlatformKeys.KEY_LONGITUDE, PlatformCommonDefaults.DEFAULT_LONGITUDE));
device.setHasSchedule(getBoolean(settings, PlatformKeys.KEY_HAS_SCHEDULE, PlatformCommonDefaults.DEFAULT_HASSCHEDULE));
device.setOwner(getString(settings, PlatformKeys.KEY_OWNER, PlatformCommonDefaults.DEFAULT_OWNER));
device.setPublicKeyPresent(getBoolean(settings, PlatformKeys.KEY_PUBLICKEYPRESENT, PlatformCommonDefaults.DEFAULT_PUBLICKEYPRESENT));
device.setActivated(getBoolean(settings, PlatformKeys.KEY_ACTIVATED, PlatformCommonDefaults.DEFAULT_ACTIVATED));
return device;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device in project open-smart-grid-platform by OSGP.
the class FindRecentDeviceSteps method theFindRecentDevicesResponseContainsAtIndex.
@Then("the find recent devices response contains at index \"{int}\"")
public void theFindRecentDevicesResponseContainsAtIndex(final Integer index, final Map<String, String> expectedDevice) throws Throwable {
final FindRecentDevicesResponse response = (FindRecentDevicesResponse) ScenarioContext.current().get(PlatformCommonKeys.RESPONSE);
final Device device = response.getDevices().get(index - 1);
assertThat(device).isNotNull();
DeviceSteps.checkDevice(expectedDevice, device);
}
use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device in project open-smart-grid-platform by OSGP.
the class DeviceInstallationMapperTest method createWsDevice.
private Device createWsDevice() {
final Device device = new Device();
device.setDeviceIdentification(DEVICE_IDENTIFICATION);
device.setAlias(ALIAS);
device.setContainerAddress(this.createWsAddress());
device.setGpsLatitude(GPS_LATITUDE);
device.setGpsLongitude(GPS_LONGITUDE);
device.setPublicKeyPresent(PUBLIC_KEY_PRESENT);
return device;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device in project open-smart-grid-platform by OSGP.
the class CreateDeviceSteps method receivingAnAddDeviceRequest.
@When("^receiving an add device request$")
public void receivingAnAddDeviceRequest(final Map<String, String> settings) {
final AddDeviceRequest request = new AddDeviceRequest();
final Device device = this.createDevice(settings);
request.setDevice(device);
try {
ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.addDevice(request));
} catch (final Exception ex) {
ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device in project open-smart-grid-platform by OSGP.
the class CreateDeviceSteps method receivingAnUpdateDeviceRequest.
@When("^receiving an update device request")
public void receivingAnUpdateDeviceRequest(final Map<String, String> settings) {
final UpdateDeviceRequest request = new UpdateDeviceRequest();
String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION);
// DeviceIdentification with only spaces
if (deviceIdentification.matches("(?!\")\\s*(?=\")")) {
deviceIdentification = deviceIdentification.replaceAll("\"", " ");
}
request.setDeviceIdentification(deviceIdentification);
final Device device = this.createDevice(settings);
request.setUpdatedDevice(device);
try {
ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.updateDevice(request));
} catch (final WebServiceSecurityException | SoapFaultClientException ex) {
ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
}
}
Aggregations