use of org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage in project open-smart-grid-platform by OSGP.
the class RequestService method enqueueAndSendRequest.
public AsyncResponse enqueueAndSendRequest(final RequestMessageMetadata requestMessageMetadata, final Serializable requestData) throws FunctionalException {
log.debug("{} called with organisation {} and device {}", requestMessageMetadata.getMessageType(), requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification());
if (requestMessageMetadata.getDeviceFunction() != null) {
this.checkAllowed(requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification(), requestMessageMetadata.getDeviceFunction());
}
final String correlationUid = this.correlationIdProviderService.getCorrelationId(requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification());
final MessageMetadata messageMetadata = requestMessageMetadata.newMessageMetadata(correlationUid);
final SmartMeteringRequestMessage message = SmartMeteringRequestMessage.newBuilder().messageMetadata(messageMetadata).request(requestData).build();
this.smartMeteringRequestMessageSender.send(message);
return this.createAsyncResponse(correlationUid, messageMetadata.getDeviceIdentification());
}
use of org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage in project open-smart-grid-platform by OSGP.
the class BundleService method enqueueBundleRequest.
public String enqueueBundleRequest(final MessageMetadata messageMetadata, final List<ActionRequest> actionList) throws FunctionalException {
final String organisationIdentification = messageMetadata.getOrganisationIdentification();
final String deviceIdentification = messageMetadata.getDeviceIdentification();
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.checkIfBundleIsAllowed(actionList, organisation, device);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final SmartMeteringRequestMessage message = SmartMeteringRequestMessage.newBuilder().messageMetadata(messageMetadata.builder().withCorrelationUid(correlationUid).build()).request(new BundleMessageRequest(actionList)).build();
this.smartMeteringRequestMessageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method testAllOperationsAreAllowed.
/**
* tests that a {@link SmartMeteringRequestMessage} is send containing all the {@link
* ActionRequest}s put in.
*
* @throws FunctionalException should not be thrown in this test
*/
@Test
void testAllOperationsAreAllowed() throws FunctionalException {
// Run the test
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withOrganisationIdentification(ORGANISATION_IDENTIFICATION).withDeviceIdentification(DEVICE_IDENTIFICATION).withMessageType(MessageType.HANDLE_BUNDLED_ACTIONS.name()).withMessagePriority(MESSAGE_PRIORITY).withBypassRetry(BYPASS_RETRY).build();
this.bundleService.enqueueBundleRequest(messageMetadata, this.actionRequestMockList);
// Verify the test
final ArgumentCaptor<SmartMeteringRequestMessage> message = ArgumentCaptor.forClass(SmartMeteringRequestMessage.class);
verify(this.smartMeteringRequestMessageSender).send(message.capture());
assertThat(message.getValue().getOrganisationIdentification()).isEqualTo(ORGANISATION_IDENTIFICATION);
assertThat(message.getValue().getDeviceIdentification()).isEqualTo(DEVICE_IDENTIFICATION);
final BundleMessageRequest requestMessage = (BundleMessageRequest) message.getValue().getRequest();
final List<ActionRequest> actionList = requestMessage.getBundleList();
assertThat(actionList.size()).isEqualTo(this.actionRequestMockList.size());
for (int i = 0; i < actionList.size(); i++) {
assertThat(actionList.get(i)).isEqualTo(this.actionRequestMockList.get(i));
}
}
Aggregations