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();
}
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);
}
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;
}
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);
}
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());
}
Aggregations