use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class ConfigurationService method handleGetKeysResponse.
public void handleGetKeysResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType resultType, final OsgpException exception, final GetKeysResponseDto getKeysResponseDto) {
log.info("handleGetKeysResponse for MessageType: {}", messageMetadata.getMessageType());
final List<KeyDto> keys = getKeysResponseDto.getKeys();
final List<GetKeysResponseData> getKeysResponseData = keys.stream().map(key -> new GetKeysResponseData(SecretType.valueOf(key.getSecretType().name()), key.getSecret())).collect(Collectors.toList());
final GetKeysResponse getKeysResponse = new GetKeysResponse(getKeysResponseData);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(resultType).withOsgpException(exception).withDataObject(getKeysResponse).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class BaseRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
Object dataObject = null;
final MessageMetadata messageMetadata = MessageMetadata.fromMessage(message);
try {
dataObject = message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("message metadata: {}", messageMetadata);
return;
}
try {
LOGGER.info("Calling application service function: {}", messageMetadata.getMessageType());
if (this.messageContainsDataObject()) {
this.handleMessage(messageMetadata, dataObject);
} else {
this.handleMessage(messageMetadata);
}
} catch (final Exception e) {
this.handleError(e, messageMetadata);
}
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method setsIpAddressFromSessionProviderIfIpAddressIsNotStatic.
@Test
void setsIpAddressFromSessionProviderIfIpAddressIsNotStatic() throws Exception {
final String communicationProvider = "comm-prov";
final String iccId = "icc-id";
final String ipAddress = IP_ADDRESS;
this.whenSessionProviderReturnsIpAddressAfterWakeUp(communicationProvider, iccId, ipAddress);
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withIpAddressStatic(false).withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(null).build();
this.domainHelperService.setIpAddressFromMessageMetadataOrSessionProvider(dlmsDevice, messageMetadata);
assertThat(dlmsDevice.getIpAddress()).isEqualTo(ipAddress);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method findDlmsDeviceMetadataNotFound.
@Test
void findDlmsDeviceMetadataNotFound() {
final MessageMetadata messageMetadata = mock(MessageMetadata.class);
when(messageMetadata.getDeviceIdentification()).thenReturn(DEVICE_IDENTIFICATION);
when(this.dlmsDeviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(null);
final FunctionalException exception = assertThrows(FunctionalException.class, () -> {
this.domainHelperService.findDlmsDevice(messageMetadata);
});
assertThat(exception.getExceptionType()).isEqualTo(FunctionalExceptionType.UNKNOWN_DEVICE);
assertThat(exception.getComponentType()).isEqualTo(ComponentType.PROTOCOL_DLMS);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class SystemEventServiceTest method verifyMaxValueNotReachedEvent.
@Test
void verifyMaxValueNotReachedEvent() {
final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(this.invocationCounterEventThreshold - 1).build();
final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
verifyNoInteractions(this.correlationIdProviderService);
verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
Aggregations