Search in sources :

Example 1 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class UpdateFirmware method theDatabaseShouldNotBeUpdatedWithTheNewDeviceFirmware.

@Then("^the database should not be updated with the new device firmware$")
public void theDatabaseShouldNotBeUpdatedWithTheNewDeviceFirmware(final Map<String, String> settings) throws Throwable {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_SMART_METER_DEVICE_IDENTIFICATION);
    final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
    assertThat(device).as("Device " + deviceIdentification + " not found.").isNotNull();
    final FirmwareFile activeFirmwareFile = device.getActiveFirmwareFile();
    if (activeFirmwareFile == null) {
        /*
       * The device has no active firmware in the database, so the
       * firmware from the settings has not been linked to the device.
       */
        return;
    }
    final String moduleVersionComm = settings.get(PlatformKeys.FIRMWARE_MODULE_VERSION_COMM);
    final String moduleVersionMa = settings.get(PlatformKeys.FIRMWARE_MODULE_VERSION_MA);
    final String moduleVersionFunc = settings.get(PlatformKeys.FIRMWARE_MODULE_VERSION_FUNC);
    assertThat(Objects.equals(moduleVersionComm, activeFirmwareFile.getModuleVersionComm()) && Objects.equals(moduleVersionMa, activeFirmwareFile.getModuleVersionMa()) && Objects.equals(moduleVersionFunc, activeFirmwareFile.getModuleVersionFunc())).as("Device " + deviceIdentification + " should not have firmware versions from the scenario after an unsuccessful update.").isFalse();
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile) Then(io.cucumber.java.en.Then)

Example 2 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class AddDeviceSteps method activateDevice.

private Device activateDevice() {
    final String deviceIdentification = this.getDeviceIdentificationFromContext();
    final Device device = this.findDeviceByDeviceIdentification(deviceIdentification);
    assertThat(device).as("Device should be in the core database for identification " + deviceIdentification).isNotNull();
    /*
     * The default result of adding a device through a service call is that
     * the device is configured to have a dynamic IP address to be obtained
     * from Jasper Wireless.
     */
    this.configureForCommunicationWithDeviceSimulator(device);
    return this.deviceRepository.save(device);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

Example 3 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method aDlmsDevice.

@Given("^a dlms device$")
public void aDlmsDevice(final Map<String, String> inputSettings) {
    final Device device = this.createDeviceInCoreDatabase(inputSettings);
    this.setScenarioContextForDevice(inputSettings, device);
    this.createDeviceAuthorisationInCoreDatabase(device);
    this.createDlmsDeviceInProtocolAdapterDatabase(inputSettings);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Given(io.cucumber.java.en.Given)

Example 4 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method theDlmsDeviceWithIdentificationExistsWithDeviceModel.

@Then("^the dlms device with identification \"([^\"]*)\" exists with device model$")
public void theDlmsDeviceWithIdentificationExistsWithDeviceModel(final String deviceIdentification, final Map<String, String> deviceModelAttributes) throws Throwable {
    this.theDlmsDeviceWithIdentificationExists(deviceIdentification);
    final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
    final DeviceModel deviceModel = device.getDeviceModel();
    assertThat(deviceModel.getModelCode()).as(PlatformKeys.DEVICEMODEL_MODELCODE).isEqualTo(deviceModelAttributes.get(PlatformKeys.DEVICEMODEL_MODELCODE));
    final Manufacturer manufacturer = deviceModel.getManufacturer();
    assertThat(manufacturer.getCode()).as(PlatformKeys.MANUFACTURER_CODE).isEqualTo(deviceModelAttributes.get(PlatformKeys.MANUFACTURER_CODE));
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) Then(io.cucumber.java.en.Then)

Example 5 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method theDlmsDeviceWithIdentificationDoesNotExist.

@Then("^the dlms device with identification \"([^\"]*)\" does not exist$")
public void theDlmsDeviceWithIdentificationDoesNotExist(final String deviceIdentification) {
    final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
    assertThat(dlmsDevice).as("DLMS device with identification " + deviceIdentification + " in protocol database").isNull();
    final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
    assertThat(device).as("DLMS device with identification " + deviceIdentification + " in core database").isNull();
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Then(io.cucumber.java.en.Then)

Aggregations

Device (org.opensmartgridplatform.domain.core.entities.Device)179 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)49 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)36 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)35 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)32 Test (org.junit.jupiter.api.Test)27 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)27 Transactional (org.springframework.transaction.annotation.Transactional)24 Then (io.cucumber.java.en.Then)21 DeviceAuthorization (org.opensmartgridplatform.domain.core.entities.DeviceAuthorization)18 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)17 CommonRequestMessage (org.opensmartgridplatform.adapter.ws.core.infra.jms.CommonRequestMessage)15 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)15 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)12 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)12 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)11 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)11 Date (java.util.Date)10 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)10 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)9