Search in sources :

Example 1 with LightMeasurementDevice

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

the class FindAllDevicesSteps method theFindAllDevicesResponseContainsAtIndex.

@Then("the find all device response contains at index {string}")
public void theFindAllDevicesResponseContainsAtIndex(final String index, final Map<String, String> expectedDevice) throws Throwable {
    final FindAllDevicesResponse response = (FindAllDevicesResponse) ScenarioContext.current().get(PlatformCommonKeys.RESPONSE);
    final Device actualDevice = response.getDevicePage().getDevices().get(Integer.valueOf(index) - 1);
    if (expectedDevice.containsKey(PlatformKeys.KEY_DEVICE_UID)) {
        assertThat(actualDevice.getDeviceUid()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_DEVICE_UID));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_DEVICE_IDENTIFICATION)) {
        assertThat(actualDevice.getDeviceIdentification()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_DEVICE_IDENTIFICATION));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_POSTCODE)) {
        assertThat(actualDevice.getContainerPostalCode()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_POSTCODE));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_CITY)) {
        assertThat(actualDevice.getContainerCity()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_CITY));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_STREET)) {
        assertThat(actualDevice.getContainerStreet()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_STREET));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_NUMBER)) {
        assertThat(actualDevice.getContainerNumber()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_NUMBER));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_LATITUDE)) {
        assertThat(actualDevice.getGpsLatitude()).isEqualTo(getFloat(expectedDevice, PlatformKeys.KEY_LATITUDE));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_LONGITUDE)) {
        assertThat(actualDevice.getGpsLongitude()).isEqualTo(getFloat(expectedDevice, PlatformKeys.KEY_LONGITUDE));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_DEVICE_TYPE)) {
        assertThat(actualDevice.getDeviceType()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_DEVICE_TYPE));
    }
    if (expectedDevice.containsKey(PlatformKeys.KEY_DEVICE_ACTIVATED)) {
        assertThat(actualDevice.isActivated()).isEqualTo(getBoolean(expectedDevice, PlatformKeys.KEY_DEVICE_ACTIVATED));
    }
    if (expectedDevice instanceof Ssld) {
        final Ssld ssld = (Ssld) actualDevice;
        if (expectedDevice.containsKey(PlatformKeys.KEY_HAS_SCHEDULE)) {
            assertThat(ssld.isHasSchedule()).isEqualTo(getBoolean(expectedDevice, PlatformKeys.KEY_HAS_SCHEDULE));
        }
        if (expectedDevice.containsKey(PlatformKeys.KEY_PUBLICKEYPRESENT)) {
            assertThat(ssld.isPublicKeyPresent()).isEqualTo(getBoolean(expectedDevice, PlatformKeys.KEY_PUBLICKEYPRESENT));
        }
    }
    if (expectedDevice instanceof LightMeasurementDevice) {
        final LightMeasurementDevice lmd = (LightMeasurementDevice) actualDevice;
        if (expectedDevice.containsKey(PlatformKeys.KEY_LMD_DESCRIPTION)) {
            assertThat(lmd.getDescription()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_LMD_DESCRIPTION));
        }
        if (expectedDevice.containsKey(PlatformKeys.KEY_LMD_CODE)) {
            assertThat(lmd.getCode()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_LMD_CODE));
        }
        if (expectedDevice.containsKey(PlatformKeys.KEY_LMD_COLOR)) {
            assertThat(lmd.getColor()).isEqualTo(getString(expectedDevice, PlatformKeys.KEY_LMD_COLOR));
        }
        if (expectedDevice.containsKey(PlatformKeys.KEY_LMD_DIGITAL_INPUT)) {
            assertThat(lmd.getDigitalInput()).isEqualTo(getShort(expectedDevice, PlatformKeys.KEY_LMD_DIGITAL_INPUT));
        }
    }
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightMeasurementDevice) Device(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Device) LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightMeasurementDevice) FindAllDevicesResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.FindAllDevicesResponse) Ssld(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Ssld) Then(io.cucumber.java.en.Then)

Example 2 with LightMeasurementDevice

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

the class LmdConverter method convertTo.

@Override
public LightMeasurementDevice convertTo(final org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice source, final Type<LightMeasurementDevice> destinationType, final MappingContext mappingContext) {
    final LightMeasurementDevice lmd = new LightMeasurementDevice();
    final String deviceIdentification = source.getDeviceIdentification();
    lmd.setDeviceUid(Base64.encodeBase64String(deviceIdentification.getBytes(StandardCharsets.US_ASCII)));
    lmd.setDeviceIdentification(deviceIdentification);
    final Address containerAddress = source.getContainerAddress();
    if (containerAddress != null) {
        lmd.setContainerPostalCode(containerAddress.getPostalCode());
        lmd.setContainerCity(containerAddress.getCity());
        lmd.setContainerStreet(containerAddress.getStreet());
        if (containerAddress.getNumber() != null) {
            lmd.setContainerNumber(containerAddress.getNumber().toString());
        }
    }
    final GpsCoordinates gpsCoordinates = source.getGpsCoordinates();
    if (gpsCoordinates != null) {
        lmd.setGpsLatitude(gpsCoordinates.getLatitude());
        lmd.setGpsLongitude(gpsCoordinates.getLongitude());
    }
    lmd.setDeviceType(source.getDeviceType());
    lmd.setActivated(source.isActivated());
    lmd.setDescription(source.getDescription());
    lmd.setCode(source.getCode());
    lmd.setColor(source.getColor());
    lmd.setDigitalInput(source.getDigitalInput());
    return lmd;
}
Also used : Address(org.opensmartgridplatform.domain.core.valueobjects.Address) LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightMeasurementDevice) GpsCoordinates(org.opensmartgridplatform.domain.core.valueobjects.GpsCoordinates)

Example 3 with LightMeasurementDevice

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

the class LmdConverter method convertFrom.

@Override
public org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice convertFrom(final LightMeasurementDevice source, final Type<org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice> destinationType, final MappingContext mappingContext) {
    final String deviceIdentification = source.getDeviceIdentification();
    final Integer containerNumber = source.getContainerNumber() == null ? null : Integer.valueOf(source.getContainerNumber());
    final Address containerAddress = new Address(source.getContainerCity(), source.getContainerPostalCode(), source.getContainerStreet(), containerNumber, null, null);
    final GpsCoordinates gpsCoordinates = new GpsCoordinates(source.getGpsLatitude(), source.getGpsLongitude());
    final org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice lmd = new org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice(deviceIdentification, null, containerAddress, gpsCoordinates, null);
    lmd.updateRegistrationData(null, source.getDeviceType());
    lmd.setDescription(source.getDescription());
    lmd.setCode(source.getCode());
    lmd.setColor(source.getColor());
    lmd.setDigitalInput(source.getDigitalInput());
    return lmd;
}
Also used : Address(org.opensmartgridplatform.domain.core.valueobjects.Address) LightMeasurementDevice(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightMeasurementDevice) GpsCoordinates(org.opensmartgridplatform.domain.core.valueobjects.GpsCoordinates)

Aggregations

LightMeasurementDevice (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightMeasurementDevice)3 Address (org.opensmartgridplatform.domain.core.valueobjects.Address)2 GpsCoordinates (org.opensmartgridplatform.domain.core.valueobjects.GpsCoordinates)2 Then (io.cucumber.java.en.Then)1 Device (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Device)1 FindAllDevicesResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.FindAllDevicesResponse)1 Ssld (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Ssld)1