Search in sources :

Example 1 with SmartMeteringRequestMessage

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());
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) RequestMessageMetadata(org.opensmartgridplatform.adapter.ws.smartmetering.endpoints.RequestMessageMetadata) SmartMeteringRequestMessage(org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage)

Example 2 with SmartMeteringRequestMessage

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;
}
Also used : Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) SmartMeteringRequestMessage(org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage) Device(org.opensmartgridplatform.domain.core.entities.Device) BundleMessageRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest)

Example 3 with SmartMeteringRequestMessage

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));
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SmartMeteringRequestMessage(org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage) ActionRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionRequest) BundleMessageRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest) Test(org.junit.jupiter.api.Test)

Aggregations

SmartMeteringRequestMessage (org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage)3 BundleMessageRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 Test (org.junit.jupiter.api.Test)1 RequestMessageMetadata (org.opensmartgridplatform.adapter.ws.smartmetering.endpoints.RequestMessageMetadata)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)1 ActionRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionRequest)1