Search in sources :

Example 1 with BundleMessageRequest

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest 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 2 with BundleMessageRequest

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest in project open-smart-grid-platform by OSGP.

the class BundleMessageProcessor method handleMessage.

@Override
protected void handleMessage(final MessageMetadata messageMetadata, final Object dataObject) throws FunctionalException {
    final BundleMessageRequest data = (BundleMessageRequest) dataObject;
    this.bundleService.handleBundle(messageMetadata, data);
}
Also used : BundleMessageRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest)

Example 3 with BundleMessageRequest

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest 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

BundleMessageRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessageRequest)3 SmartMeteringRequestMessage (org.opensmartgridplatform.adapter.ws.smartmetering.infra.jms.SmartMeteringRequestMessage)2 Test (org.junit.jupiter.api.Test)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 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1