Search in sources :

Example 1 with Device

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;
}
Also used : DeviceModel(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.DeviceModel) AddressBuilder(org.opensmartgridplatform.cucumber.platform.core.builders.AddressBuilder) Device(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device)

Example 2 with 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);
}
Also used : FindRecentDevicesResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.FindRecentDevicesResponse) Device(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device) Then(io.cucumber.java.en.Then)

Example 3 with 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;
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice) Device(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device)

Example 4 with 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);
    }
}
Also used : Device(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device) AddDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.AddDeviceRequest) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) WebServiceSecurityException(org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException) When(io.cucumber.java.en.When)

Example 5 with Device

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);
    }
}
Also used : UpdateDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateDeviceRequest) Device(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) WebServiceSecurityException(org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException) When(io.cucumber.java.en.When)

Aggregations

Device (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.Device)8 Then (io.cucumber.java.en.Then)2 When (io.cucumber.java.en.When)2 FindRecentDevicesResponse (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.FindRecentDevicesResponse)2 LightMeasurementDevice (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice)2 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)2 WebServiceSecurityException (org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException)2 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)2 Test (org.junit.jupiter.api.Test)1 AddDeviceRequest (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.AddDeviceRequest)1 DeviceModel (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.DeviceModel)1 UpdateDeviceRequest (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateDeviceRequest)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 AddressBuilder (org.opensmartgridplatform.cucumber.platform.core.builders.AddressBuilder)1 Address (org.opensmartgridplatform.domain.core.valueobjects.Address)1 GpsCoordinates (org.opensmartgridplatform.domain.core.valueobjects.GpsCoordinates)1