use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class SetDeviceCommunicationSettingsSteps method theDeviceShouldBeInTheDatabaseWithAttributes.
@Then("^the device \"([^\"]*)\" should be in the database with attributes$")
public void theDeviceShouldBeInTheDatabaseWithAttributes(final String deviceIdentification, final Map<String, String> settings) throws Throwable {
final DlmsDevice device = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
final int expectedResult = getInteger(settings, PlatformSmartmeteringKeys.CHALLENGE_LENGTH, PlatformSmartmeteringDefaults.CHALLENGE_LENGTH);
assertThat(device.getChallengeLength().intValue()).as("Number of challenge length should match").isEqualTo(expectedResult);
assertThat(device.isWithListSupported()).as("With list supported should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.WITH_LIST_SUPPORTED));
assertThat(device.isSelectiveAccessSupported()).as("Selective access supported should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.SELECTIVE_ACCESS_SUPPORTED));
assertThat(device.isIpAddressIsStatic()).as("IP address is static should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.IP_ADDRESS_IS_STATIC));
assertThat(device.isUseSn()).as("Use SN should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.USE_SN));
assertThat(device.isUseHdlc()).as("Use HDLC should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.USE_HDLC));
assertThat(device.isPolyphase()).as("Polyphase should match").isEqualTo(getBoolean(settings, PlatformSmartmeteringKeys.POLYPHASE));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method aValidMbusUserKeyIsStored.
@Then("^a valid m-bus user key is stored$")
public void aValidMbusUserKeyIsStored(final Map<String, String> settings) {
final String keyDeviceIdentification = PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION;
final String deviceIdentification = settings.get(keyDeviceIdentification);
assertThat(deviceIdentification).as("The M-Bus device identification must be in the step data for key " + keyDeviceIdentification).isNotNull();
final String deviceDescription = "M-Bus device with identification " + deviceIdentification;
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
assertThat(dlmsDevice).as(deviceDescription + " must be in the protocol database").isNotNull();
final List<DbEncryptedSecret> securityKeys = this.findAllSecretsForDevice(deviceIdentification);
int numberOfMbusDefaultKeys = 0;
int numberOfMbusUserKeys = 0;
int numberOfValidMbusUserKeys = 0;
for (final DbEncryptedSecret securityKey : securityKeys) {
switch(securityKey.getSecretType()) {
case G_METER_MASTER_KEY:
numberOfMbusDefaultKeys += 1;
break;
case G_METER_ENCRYPTION_KEY:
numberOfMbusUserKeys += 1;
if (securityKey.getSecretStatus().equals(SecretStatus.ACTIVE)) {
numberOfValidMbusUserKeys += 1;
}
break;
default:
}
}
assertThat(numberOfMbusDefaultKeys).as("Number of M-Bus Default keys stored").isEqualTo(1);
assertThat(numberOfMbusUserKeys > 0).as("At least one M-Bus User key must be stored").isTrue();
assertThat(numberOfValidMbusUserKeys).as("Number of valid M-Bus User keys stored").isEqualTo(1);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method theKeyprocessingLockShouldBeRemovedFromDlmsDeviceWithIdentification.
@Then("^the keyprocessing lock should be removed from off dlms device with identification \"([^\"]*)\"$")
public void theKeyprocessingLockShouldBeRemovedFromDlmsDeviceWithIdentification(final String deviceIdentification) {
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
assertThat(dlmsDevice).as("DLMS device with identification " + deviceIdentification + " in protocol database").isNotNull();
assertThat(dlmsDevice.getKeyProcessingStartTime()).as("DLMS device with identification " + deviceIdentification + " should not have lock on keyprocessing in protocol database").isNull();
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method theStoredMbusDefaultKeysIsNotEqualToTheReceivedKey.
@Then("^the stored M-Bus Default key is not equal to the received key$")
public void theStoredMbusDefaultKeysIsNotEqualToTheReceivedKey() {
final String keyDeviceIdentification = PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION;
final String deviceIdentification = (String) ScenarioContext.current().get(keyDeviceIdentification);
assertThat(deviceIdentification).as("Device identification must be in the scenario context for key " + keyDeviceIdentification).isNotNull();
final String deviceDescription = "DLMS device with identification " + deviceIdentification;
final DlmsDevice dlmsDevice = this.findExistingDlmsDevice(deviceIdentification);
final DbEncryptedSecret mbusDefaultKey = this.findExistingSecurityKey(dlmsDevice, G_METER_MASTER_KEY, "M-Bus Default key");
final String receivedMbusDefaultKey = (String) ScenarioContext.current().get(PlatformSmartmeteringKeys.MBUS_DEFAULT_KEY);
assertThat(mbusDefaultKey.getEncodedSecret()).as("Stored M-Bus Default key for " + deviceDescription + " must be different from received key").isNotEqualTo(receivedMbusDefaultKey);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method createDlmsDeviceInProtocolAdapterDatabase.
private void createDlmsDeviceInProtocolAdapterDatabase(final Map<String, String> inputSettings) {
final ProtocolInfo protocolInfo = this.getProtocolInfo(inputSettings);
final DlmsDeviceBuilder dlmsDeviceBuilder = new DlmsDeviceBuilder().setProtocolName(protocolInfo);
final DlmsDevice dlmsDevice = dlmsDeviceBuilder.withSettings(inputSettings).build();
this.dlmsDeviceRepository.save(dlmsDevice);
this.createDlmsDeviceInSecretManagementDatabase(dlmsDevice, inputSettings);
}
Aggregations