Search in sources :

Example 1 with LightMeasurementDevice

use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice in project open-smart-grid-platform by OSGP.

the class CreateLightMeasurementDeviceSteps method createLightMeasurementDevice.

private LightMeasurementDevice createLightMeasurementDevice(final Map<String, String> settings) {
    final LightMeasurementDevice lmd = new LightMeasurementDevice();
    lmd.setAlias(getString(settings, PlatformKeys.ALIAS, PlatformCommonDefaults.DEFAULT_ALIAS));
    lmd.setContainerAddress(new AddressBuilder().withSettings(settings).build());
    lmd.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));
    lmd.setDeviceModel(deviceModel);
    lmd.setGpsLatitude(getFloat(settings, PlatformKeys.KEY_LATITUDE, PlatformCommonDefaults.DEFAULT_LATITUDE));
    lmd.setGpsLongitude(getFloat(settings, PlatformKeys.KEY_LONGITUDE, PlatformCommonDefaults.DEFAULT_LONGITUDE));
    lmd.setOwner(getString(settings, PlatformKeys.KEY_OWNER, PlatformCommonDefaults.DEFAULT_OWNER));
    lmd.setActivated(getBoolean(settings, PlatformKeys.KEY_ACTIVATED, PlatformCommonDefaults.DEFAULT_ACTIVATED));
    lmd.setDescription(getString(settings, PlatformKeys.KEY_LMD_DESCRIPTION, PlatformCommonDefaults.DEFAULT_LMD_DESCRIPTION));
    lmd.setCode(getString(settings, PlatformKeys.KEY_LMD_CODE, PlatformCommonDefaults.DEFAULT_LMD_CODE));
    lmd.setColor(getString(settings, PlatformKeys.KEY_LMD_COLOR, PlatformCommonDefaults.DEFAULT_LMD_COLOR));
    lmd.setDigitalInput(getShort(settings, PlatformKeys.KEY_LMD_DIGITAL_INPUT, PlatformCommonDefaults.DEFAULT_LMD_DIGITAL_INPUT));
    return lmd;
}
Also used : DeviceModel(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.DeviceModel) AddressBuilder(org.opensmartgridplatform.cucumber.platform.core.builders.AddressBuilder) LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice)

Example 2 with LightMeasurementDevice

use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice in project open-smart-grid-platform by OSGP.

the class CreateLightMeasurementDeviceSteps method receivingAnAddLightMeasurementDeviceRequest.

@When("^receiving an add light measurement device request$")
public void receivingAnAddLightMeasurementDeviceRequest(final Map<String, String> settings) {
    final AddLightMeasurementDeviceRequest request = new AddLightMeasurementDeviceRequest();
    final LightMeasurementDevice lmd = this.createLightMeasurementDevice(settings);
    request.setLightMeasurementDevice(lmd);
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.addLightMeasurementDevice(request));
    } catch (final Exception ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice) AddLightMeasurementDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.AddLightMeasurementDeviceRequest) When(io.cucumber.java.en.When)

Example 3 with LightMeasurementDevice

use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice in project open-smart-grid-platform by OSGP.

the class CreateLightMeasurementDeviceSteps method receivingAnUpdateLightMeasurementDeviceRequest.

@When("^receiving an update light measurement device request$")
public void receivingAnUpdateLightMeasurementDeviceRequest(final Map<String, String> settings) {
    final UpdateLightMeasurementDeviceRequest request = new UpdateLightMeasurementDeviceRequest();
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    request.setDeviceIdentification(deviceIdentification);
    final LightMeasurementDevice lmd = this.createLightMeasurementDevice(settings);
    request.setUpdatedLightMeasurementDevice(lmd);
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.updateLightMeasurementDevice(request));
    } catch (final Exception ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice) UpdateLightMeasurementDeviceRequest(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateLightMeasurementDeviceRequest) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) When(io.cucumber.java.en.When)

Example 4 with LightMeasurementDevice

use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice in project open-smart-grid-platform by OSGP.

the class DeviceInstallationMapperTest method testConversionFromWsLmdToLmd.

@Test
public void testConversionFromWsLmdToLmd() {
    // Arrange
    final LightMeasurementDevice lmd = this.createWsLmd();
    final org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice expected = this.createLmd();
    // Act
    final org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice actual = this.mapper.map(lmd, org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice.class);
    // Assert
    assertThat(actual).isEqualToIgnoringGivenFields(expected, "creationTime", "modificationTime");
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice) Test(org.junit.jupiter.api.Test)

Example 5 with LightMeasurementDevice

use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice in project open-smart-grid-platform by OSGP.

the class DeviceInstallationMapperTest method createWsLmd.

private LightMeasurementDevice createWsLmd() {
    final LightMeasurementDevice lmd = new LightMeasurementDevice();
    lmd.setDeviceIdentification(DEVICE_IDENTIFICATION);
    lmd.setAlias(ALIAS);
    lmd.setContainerAddress(this.createWsAddress());
    lmd.setGpsLatitude(GPS_LATITUDE);
    lmd.setGpsLongitude(GPS_LONGITUDE);
    lmd.setDescription(DESCRIPTION);
    lmd.setCode(CODE);
    lmd.setColor(COLOR);
    lmd.setDigitalInput(DIGITAL_INPUT);
    return lmd;
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice)

Aggregations

LightMeasurementDevice (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.LightMeasurementDevice)5 When (io.cucumber.java.en.When)2 Test (org.junit.jupiter.api.Test)1 AddLightMeasurementDeviceRequest (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.AddLightMeasurementDeviceRequest)1 DeviceModel (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.DeviceModel)1 UpdateLightMeasurementDeviceRequest (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateLightMeasurementDeviceRequest)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 AddressBuilder (org.opensmartgridplatform.cucumber.platform.core.builders.AddressBuilder)1