use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareRequestMessageProcessorTest method processMessageTaskShouldNotUpdateFirmwareWhenFirmwareFileNotAvailable.
@Test
void processMessageTaskShouldNotUpdateFirmwareWhenFirmwareFileNotAvailable() throws JMSException, OsgpException {
// Arrange
final String firmwareIdentification = "unavailable";
final String deviceIdentification = "unavailableEither";
final UpdateFirmwareRequestDto updateFirmwareRequestDto = new UpdateFirmwareRequestDto(firmwareIdentification, deviceIdentification);
final ObjectMessage message = new ObjectMessageBuilder().withObject(updateFirmwareRequestDto).withCorrelationUid("123456").build();
final MessageMetadata messageMetadata = MessageMetadata.fromMessage(message);
when(this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)).thenReturn(false);
// Act
this.processor.processMessageTasks(message.getObject(), messageMetadata, this.dlmsConnectionManagerMock, this.device);
// Assert
verify(this.firmwareService, times(0)).updateFirmware(nullable(DlmsConnectionManager.class), same(this.device), same(updateFirmwareRequestDto), any(MessageMetadata.class));
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method enqueueSetLightRequest.
public String enqueueSetLightRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Size(min = 1, max = 6) @Valid final List<LightValue> lightValues, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueSetLightRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final LightValueMessageDataContainer lightValueMessageDataContainer = new LightValueMessageDataContainer(lightValues);
final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightValueMessageDataContainer).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method enqueueResumeScheduleRequest.
public String enqueueResumeScheduleRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final ResumeScheduleData resumeScheduleData, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.RESUME_SCHEDULE);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueResumeScheduleRequest called with organisation {}, device {} and resumeScheduleData {} ", organisationIdentification, deviceIdentification, resumeScheduleData);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.RESUME_SCHEDULE.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(resumeScheduleData).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class SystemEventService method verifySystemEventThresholdReachedEvent.
public void verifySystemEventThresholdReachedEvent(final DlmsDevice device, final MessageMetadata sourceMessageMetadata) {
if (device.getInvocationCounter() == null || device.getInvocationCounter() < this.invocationCounterEventThreshold) {
return;
}
final String message = String.format("Invocation counter for device %s, has a higher value %s than the threshold configured %s, an event will be published", device.getDeviceIdentification(), device.getInvocationCounter(), this.invocationCounterEventThreshold);
log.info(message);
final SystemEventDto systemEventDto = new SystemEventDto(device.getDeviceIdentification(), SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED, new Date(), message);
final String correlationId = this.correlationIdProviderService.getCorrelationId(sourceMessageMetadata.getOrganisationIdentification(), device.getDeviceIdentification());
final MessageMetadata messageMetadata = new Builder().withDeviceIdentification(device.getDeviceIdentification()).withCorrelationUid(correlationId).withOrganisationIdentification(sourceMessageMetadata.getOrganisationIdentification()).withIpAddress(sourceMessageMetadata.getIpAddress()).withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).withMessageType(MessageType.SYSTEM_EVENT.name()).withDomain(sourceMessageMetadata.getDomain()).withDomainVersion(sourceMessageMetadata.getDomainVersion()).build();
final RequestMessage requestMessage = new RequestMessage(messageMetadata, systemEventDto);
log.info("Sending system event to GXF with correlation ID: {}", correlationId);
this.osgpRequestMessageSender.send(requestMessage, MessageType.SYSTEM_EVENT.name(), messageMetadata);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata 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