Skip to content

Commit

Permalink
SMHE-1839 Voorkomen foutmelding mbus key uitlezing bij key-status gas…
Browse files Browse the repository at this point in the history
…meter.

do not throw exception in case of empty channel

Signed-off-by: Natasja <[email protected]>
  • Loading branch information
natasja-n committed Feb 7, 2024
1 parent 82ea360 commit 6f1284e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public void theGetMBusEncryptionKeyStatusByChannelResponseIsReturned(
final GetMbusEncryptionKeyStatusByChannelResponse response =
this.smartMeterConfigurationClient.retrieveGetMbusEncryptionKeyStatusByChannelResponse(
asyncRequest);
final EncryptionKeyStatus expectedEncryptionKeyStatus = EncryptionKeyStatus.valueOf(
settings.get(PlatformSmartmeteringKeys.KEY_DEVICE_ENCRYPTION_KEY_STATUS));

assertThat(response.getResult())
.as(OPERATION + ", Checking result:")
.isEqualTo(OsgpResultType.OK);
assertThat(response.getEncryptionKeyStatus())
.as(OPERATION + ", Checking EncryptionKeyStatus:")
.isEqualTo(EncryptionKeyStatus.ENCRYPTION_KEY_IN_USE);
.isEqualTo(expectedEncryptionKeyStatus);
}

@Then("^the get M-Bus encryption key status by channel request should return an exception$")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,49 @@ Feature: SmartMetering - Configuration - M-Bus encryption key status by channel
When a get M-Bus encryption key status by channel request is received
| DeviceIdentification | TEST1024000000001 |
| Channel | 1 |
Then the get M-Bus encryption key status request should return an exception
And a SOAP fault should have been returned
| Code | 219 |
| Message | NO_DEVICE_FOUND_ON_CHANNEL |
Then the get M-Bus encryption key status by channel response is returned
| DeviceIdentification | TEST1024000000001 |
| Channel | 1 |
| EncryptionKeyStatus | NO_ENCRYPTION_KEY |

Scenario: Get M-Bus encryption key status from coupled M-Bus device by using Channel id and Gateway device id
Given a dlms device
| DeviceIdentification | TEST1024000000001 |
| DeviceType | SMART_METER_E |
And a dlms device
| DeviceIdentification | TESTG101205673101 |
| DeviceType | SMART_METER_G |
| GatewayDeviceIdentification | TEST1024000000001 |
| Channel | 1 |
| MbusIdentificationNumber | 12056731 |
| MbusManufacturerIdentification | LGB |
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
And device simulation of "TEST1024000000001" with M-Bus client version 0 values for channel 1
| MbusPrimaryAddress | 9 |
| MbusIdentificationNumber | 12056731 |
| MbusManufacturerIdentification | LGB |
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
| MbusEncryptionKeyStatus | 4 |
And device simulation of "TEST1024000000001" with M-Bus client version 0 values for channel 2
| MbusPrimaryAddress | 0 |
| MbusIdentificationNumber | 0 |
| MbusManufacturerIdentification | 0 |
| MbusVersion | 0 |
| MbusDeviceTypeIdentification | 0 |
| MbusEncryptionKeyStatus | 0 |
When a get M-Bus encryption key status by channel request is received
| DeviceIdentification | TEST1024000000001 |
| Channel | 1 |
Then the get M-Bus encryption key status by channel response is returned
| DeviceIdentification | TEST1024000000001 |
| Channel | 1 |
| EncryptionKeyStatus | ENCRYPTION_KEY_IN_USE |
When a get M-Bus encryption key status by channel request is received
| DeviceIdentification | TEST1024000000001 |
| Channel | 2 |
Then the get M-Bus encryption key status by channel response is returned
| DeviceIdentification | TEST1024000000001 |
| Channel | 2 |
| EncryptionKeyStatus | NO_ENCRYPTION_KEY |
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusByChannelRequestDataDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusByChannelResponseDto;
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException;
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -53,8 +50,10 @@ public GetMbusEncryptionKeyStatusByChannelResponseDto execute(
if (!channelElementValues.hasChannel()
|| !channelElementValues.hasDeviceTypeIdentification()
|| !channelElementValues.hasManufacturerIdentification()) {
throw new FunctionalException(
FunctionalExceptionType.NO_DEVICE_FOUND_ON_CHANNEL, ComponentType.DOMAIN_SMART_METERING);
return new GetMbusEncryptionKeyStatusByChannelResponseDto(
device.getDeviceIdentification(),
EncryptionKeyStatusTypeDto.NO_ENCRYPTION_KEY,
request.getChannel());
}

final EncryptionKeyStatusTypeDto encryptionKeyStatusType =
Expand Down

0 comments on commit 6f1284e

Please sign in to comment.