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;
}
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);
}
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));
}
}
Aggregations