use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder in project open-smart-grid-platform by OSGP.
the class SystemEventServiceTest method verifyMaxValueNotReachedEvent.
@Test
void verifyMaxValueNotReachedEvent() {
final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(this.invocationCounterEventThreshold - 1).build();
final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
verifyNoInteractions(this.correlationIdProviderService);
verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder in project open-smart-grid-platform by OSGP.
the class SystemEventServiceTest method verifyInvocationCounterIsNull.
@Test
void verifyInvocationCounterIsNull() {
final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(null).build();
final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
verifyNoInteractions(this.correlationIdProviderService);
verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder in project open-smart-grid-platform by OSGP.
the class SystemEventServiceTest method verifyMaxValueReachedEvent.
@Test
void verifyMaxValueReachedEvent() {
final DlmsDevice device = new DlmsDeviceBuilder().withDeviceIdentification("device-1").withInvocationCounter(this.invocationCounterEventThreshold).build();
final MessageMetadata messageMetadata = new Builder().withIpAddress("127.0-.0.1").withOrganisationIdentification("org-id").withDomain("domain").withDomainVersion("1.0").build();
when(this.correlationIdProviderService.getCorrelationId(messageMetadata.getOrganisationIdentification(), device.getDeviceIdentification())).thenReturn("corr-id");
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
final ArgumentCaptor<MessageMetadata> messageMetadataCaptor = ArgumentCaptor.forClass(MessageMetadata.class);
final ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
verify(this.osgpRequestMessageSender).send(requestMessageCaptor.capture(), eq(MessageType.SYSTEM_EVENT.name()), messageMetadataCaptor.capture());
final RequestMessage requestMessage = requestMessageCaptor.getValue();
assertThat(requestMessage.getDeviceIdentification()).isEqualTo(device.getDeviceIdentification());
assertThat(requestMessage.getCorrelationUid()).isEqualTo("corr-id");
assertThat(requestMessage.getOrganisationIdentification()).isEqualTo(messageMetadata.getOrganisationIdentification());
assertThat(requestMessage.getIpAddress()).isEqualTo(messageMetadata.getIpAddress());
assertThat(requestMessage.getRequest()).isInstanceOf(SystemEventDto.class);
final SystemEventDto systemEventDto = (SystemEventDto) requestMessage.getRequest();
assertThat(systemEventDto.getDeviceIdentification()).isEqualTo(device.getDeviceIdentification());
assertThat(systemEventDto.getSystemEventType()).isEqualTo(SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED);
assertThat(systemEventDto.getTimestamp()).isNotNull();
final MessageMetadata metadata = messageMetadataCaptor.getValue();
assertThat(metadata.getDeviceIdentification()).isEqualTo(device.getDeviceIdentification());
assertThat(metadata.getCorrelationUid()).isEqualTo("corr-id");
assertThat(metadata.getOrganisationIdentification()).isEqualTo(messageMetadata.getOrganisationIdentification());
assertThat(metadata.getIpAddress()).isEqualTo(messageMetadata.getIpAddress());
assertThat(metadata.getMessagePriority()).isEqualTo(MessagePriorityEnum.HIGH.getPriority());
assertThat(metadata.getMessageType()).isEqualTo(MessageType.SYSTEM_EVENT.name());
assertThat(metadata.getDomain()).isEqualTo(messageMetadata.getDomain());
assertThat(metadata.getDomainVersion()).isEqualTo(messageMetadata.getDomainVersion());
}
Aggregations