Search in sources :

Example 1 with FirmwareFile

use of org.opensmartgridplatform.domain.core.entities.FirmwareFile 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 FirmwareFile

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

the class DeviceFirmwareFileSteps method theDeviceFirmwareFileExists.

@Then("^the device firmware file exists$")
public void theDeviceFirmwareFileExists(final Map<String, String> settings) {
    final String deviceIdentification = settings.get(PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
    final FirmwareFile firmwareFile = this.getFirmwareFile(getString(settings, PlatformKeys.FIRMWARE_FILE_FILENAME));
    final DeviceFirmwareFile deviceFirmwareFile = Wait.untilAndReturn(() -> {
        final DeviceFirmwareFile entity = this.deviceFirmwareFileRepository.findByDeviceAndFirmwareFile(device, firmwareFile);
        if (entity == null) {
            throw new Exception("Device with identification [" + deviceIdentification + "]");
        }
        return entity;
    });
    assertThat(deviceFirmwareFile.getDevice().getDeviceIdentification()).isEqualTo(deviceIdentification);
}
Also used : DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) Device(org.opensmartgridplatform.domain.core.entities.Device) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile) Then(io.cucumber.java.en.Then)

Example 3 with FirmwareFile

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

the class DeviceFirmwareFileSteps method getFirmwareFile.

private FirmwareFile getFirmwareFile(final String firmwareFileName) {
    FirmwareFile firmwareFile;
    if (StringUtils.isEmpty(firmwareFileName)) {
        final List<FirmwareFile> firmwareFiles = this.firmwareFileRepository.findAll();
        firmwareFile = firmwareFiles.get(firmwareFiles.size() - 1);
    } else {
        final List<FirmwareFile> firmwareFiles = this.firmwareFileRepository.findByFilename(firmwareFileName);
        firmwareFile = firmwareFiles.get(0);
    }
    return firmwareFile;
}
Also used : DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile)

Example 4 with FirmwareFile

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

the class FirmwareFileSteps method anInstalledFirmwareFileForAnSsld.

@Given("^an installed firmware file for an ssld$")
@Transactional("txMgrCore")
public void anInstalledFirmwareFileForAnSsld(final Map<String, String> settings) {
    final Ssld ssld = this.ssldRepository.findByDeviceIdentification(getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final FirmwareFile firmware = this.firmwareFileRepository.findByIdentification(getString(settings, PlatformKeys.FIRMWARE_FILE_FILENAME, PlatformDefaults.FIRMWARE_FILENAME));
    final Date installationDate = new Date();
    final String installedByUser = "installed by test code";
    final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(ssld, firmware, installationDate, installedByUser);
    this.deviceFirmwareFileRepository.save(deviceFirmwareFile);
}
Also used : DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile) Date(java.util.Date) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld) Given(io.cucumber.java.en.Given) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with FirmwareFile

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

the class FirmwareSteps method assertFirmwareFileExists.

protected void assertFirmwareFileExists(final String identification, final Map<String, String> firmwareFileProperties) {
    final Firmware expectedFirmware = this.createAndGetFirmware(firmwareFileProperties);
    final FirmwareFile databaseFirmwareFile = this.firmwareFileRepository.findByIdentification(identification);
    assertThat(databaseFirmwareFile).isNotNull().as("Firmware File {} should exist", identification);
    assertThat(databaseFirmwareFile.getDescription()).isEqualTo(expectedFirmware.getDescription());
    assertThat(databaseFirmwareFile.getFile()).isEqualTo(expectedFirmware.getFile());
    assertThat(databaseFirmwareFile.getFilename()).isEqualTo(expectedFirmware.getFilename());
}
Also used : Firmware(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.Firmware) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile)

Aggregations

FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)39 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)33 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)17 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)16 Device (org.opensmartgridplatform.domain.core.entities.Device)11 Test (org.junit.jupiter.api.Test)9 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)9 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)7 Manufacturer (org.opensmartgridplatform.domain.core.entities.Manufacturer)7 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)6 ArrayList (java.util.ArrayList)5 Firmware (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.Firmware)5 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)5 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)5 Then (io.cucumber.java.en.Then)4 Date (java.util.Date)4 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)4 Given (io.cucumber.java.en.Given)3