use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessorTest method processMessageShouldSendNotOkResponseMessageContainingOriginalFirmwareUpdateRequest.
@Test
void processMessageShouldSendNotOkResponseMessageContainingOriginalFirmwareUpdateRequest() throws OsgpException, JMSException {
// arrange
final FirmwareFileDto firmwareFileDto = this.setupFirmwareFileDto();
final ResponseMessage responseMessage = this.setupResponseMessage(firmwareFileDto);
final ObjectMessage message = new ObjectMessageBuilder().withMessageType(MessageType.GET_FIRMWARE_FILE.name()).withObject(responseMessage).build();
final MessageMetadata messageMetadata = new MessageMetadata.Builder(MessageMetadata.fromMessage(message)).withMessageType(MessageType.UPDATE_FIRMWARE.name()).build();
final ArgumentCaptor<ResponseMessage> responseMessageArgumentCaptor = ArgumentCaptor.forClass(ResponseMessage.class);
when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(this.dlmsDevice);
when(this.dlmsConnectionManagerMock.getDlmsMessageListener()).thenReturn(this.dlmsMessageListenerMock);
when(this.firmwareService.updateFirmware(same(this.dlmsConnectionManagerMock), same(this.dlmsDevice), same(firmwareFileDto), any(MessageMetadata.class))).thenThrow(new ProtocolAdapterException("Firmware file fw is not available."));
// act
this.getFirmwareFileResponseMessageProcessor.processMessageTasks(message.getObject(), messageMetadata, this.dlmsConnectionManagerMock);
// assert
verify(this.responseMessageSender, times(1)).send(responseMessageArgumentCaptor.capture());
final ResponseMessage capturedValue = responseMessageArgumentCaptor.getValue();
assertThat(((UpdateFirmwareRequestDto) capturedValue.getDataObject()).getFirmwareIdentification()).isSameAs(firmwareFileDto.getFirmwareIdentification());
assertThat(capturedValue.getResult()).isSameAs(ResponseMessageResultType.NOT_OK);
assertThat(capturedValue.bypassRetry()).isFalse();
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method getSetLightResponse.
@PayloadRoot(localPart = "SetLightAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetLightResponse getSetLightResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetLightAsyncRequest request) throws OsgpException {
LOGGER.info("Get Set Light Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
final SetLightResponse response = new SetLightResponse();
try {
final ResponseMessage message = this.adHocManagementService.dequeueSetLightResponse(request.getAsyncRequest().getCorrelationUid());
if (message != null) {
response.setResult(OsgpResultType.fromValue(message.getResult().getValue()));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method getResumeScheduleResponse.
@PayloadRoot(localPart = "ResumeScheduleAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public ResumeScheduleResponse getResumeScheduleResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ResumeScheduleAsyncRequest request) throws OsgpException {
LOGGER.info("Resume Schedule Async Request received from organisation: {} for device: {}.", organisationIdentification, request.getAsyncRequest().getDeviceId());
final ResumeScheduleResponse response = new ResumeScheduleResponse();
try {
final ResponseMessage message = this.adHocManagementService.dequeueResumeScheduleResponse(request.getAsyncRequest().getCorrelationUid());
if (message != null) {
response.setResult(OsgpResultType.fromValue(message.getResult().getValue()));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method getSetTransitionResponse.
@PayloadRoot(localPart = "SetTransitionAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetTransitionResponse getSetTransitionResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetTransitionAsyncRequest request) throws OsgpException {
LOGGER.info("Get Set Transition Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
final SetTransitionResponse response = new SetTransitionResponse();
try {
final ResponseMessage message = this.adHocManagementService.dequeueSetTransitionResponse(request.getAsyncRequest().getCorrelationUid());
if (message != null) {
response.setResult(OsgpResultType.fromValue(message.getResult().getValue()));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method getGetStatusResponse.
@PayloadRoot(localPart = "GetStatusAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetStatusResponse getGetStatusResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetStatusAsyncRequest request) throws OsgpException {
LOGGER.info("Get Status Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
final GetStatusResponse response = new GetStatusResponse();
try {
final ResponseMessage message = this.adHocManagementService.dequeueGetStatusResponse(request.getAsyncRequest().getCorrelationUid());
if (message != null) {
response.setResult(OsgpResultType.fromValue(message.getResult().getValue()));
response.setStatus(this.adHocManagementMapper.map(message.getDataObject(), org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Status.class));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations