use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class ConfigurationServiceTest method getKeys.
@Test
void getKeys() throws FunctionalException {
// SETUP
when(this.domainHelperService.findSmartMeter(DEVICE_IDENTIFICATION)).thenReturn(device);
// CALL
this.instance.getKeys(messageMetadata, getKeysRequestData);
// VERIFY
final GetKeysRequestDto expectedRequestDto = new GetKeysRequestDto(Arrays.asList(SecretTypeDto.E_METER_AUTHENTICATION_KEY, SecretTypeDto.E_METER_MASTER_KEY));
final MessageMetadata expectedMessageMetadata = messageMetadata.builder().withIpAddress(IP_ADDRESS).withNetworkSegmentIds(BASE_TRANSCEIVER_STATION_ID, CELL_ID).build();
verify(this.osgpCoreRequestMessageSender).send(this.requestMessageCaptor.capture(), this.messageMetadataCaptor.capture());
assertThat(this.requestMessageCaptor.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestDto);
assertThat(this.messageMetadataCaptor.getValue()).isEqualToComparingFieldByField(expectedMessageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class GetKeysServiceTest method getKeysWithoutKeyTypes.
@Test
void getKeysWithoutKeyTypes() {
final GetKeysRequestDto request = new GetKeysRequestDto(Collections.emptyList());
final GetKeysResponseDto response = this.getKeysService.getKeys(DEVICE, request, messageMetadata);
assertThat(response).isNotNull();
assertThat(response.getKeys()).isEmpty();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class GetKeysRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(GetKeysRequestDto.class, requestObject);
final GetKeysRequestDto requestDto = (GetKeysRequestDto) requestObject;
return this.configurationService.requestGetKeys(device, requestDto, messageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class ConfigurationService method getKeys.
public void getKeys(final MessageMetadata messageMetadata, final GetKeysRequestData getKeysRequestData) throws FunctionalException {
log.info("getKeys for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
final List<SecretTypeDto> secretTypes = getKeysRequestData.getSecretTypes().stream().map(secretType -> SecretTypeDto.valueOf(secretType.name())).collect(Collectors.toList());
final GetKeysRequestDto requestDto = new GetKeysRequestDto(secretTypes);
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Aggregations