Search in sources :

Example 1 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class OsgpCoreRequestSteps method whenIReceiveAConnectRequestForIEC60870DeviceFromOsgpCore.

@When("I receive a connect request for IEC60870 device {string} from osgp core")
public void whenIReceiveAConnectRequestForIEC60870DeviceFromOsgpCore(final String deviceIdentification) throws Exception {
    this.connectionSteps.prepareForConnect(deviceIdentification);
    final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.CONNECT.name()).withObject(new ConnectRequestDto()).build();
    this.messageListener.onMessage(message);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) ConnectRequestDto(org.opensmartgridplatform.dto.da.ConnectRequestDto) When(io.cucumber.java.en.When)

Example 2 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class OsgpCoreRequestSteps method whenIReceiveAGetLightSensorStatusRequestMessageForIEC60870DeviceFromOsgpCore.

@When("I receive a get light sensor status request message for IEC60870 device {string} from osgp core")
public void whenIReceiveAGetLightSensorStatusRequestMessageForIEC60870DeviceFromOsgpCore(final String deviceIdentification) throws Exception {
    this.connectionSteps.prepareForConnect(deviceIdentification);
    final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.GET_LIGHT_SENSOR_STATUS.name()).withObject(new ConnectRequestDto()).build();
    this.messageListener.onMessage(message);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) ConnectRequestDto(org.opensmartgridplatform.dto.da.ConnectRequestDto) When(io.cucumber.java.en.When)

Example 3 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class OsgpCoreRequestSteps method whenIReceiveRequestForIec60870Device.

@When("I receive a request for the IEC60870 device")
public void whenIReceiveRequestForIec60870Device() throws JMSException {
    final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification(DEFAULT_DEVICE_IDENTIFICATION).withMessageType(DEFAULT_MESSAGE_TYPE).withObject(new GetHealthStatusRequestDto()).build();
    this.messageListener.onMessage(message);
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) ObjectMessage(javax.jms.ObjectMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) When(io.cucumber.java.en.When)

Example 4 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class PushNotificationAlarmMessageProcessorTest method init.

@BeforeEach
public void init() throws JMSException, UnknownEntityException {
    final String correlationUid = "corr-uid-1";
    final String organisationIdentification = "test-org";
    final String ipAddress = "127.0.0.1";
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisationIdentification, DEVICE_IDENTIFICATION, ipAddress, null, null, this.pushNotificationAlarm);
    this.message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withMessageType(MessageType.PUSH_NOTIFICATION_ALARM.name()).withDeviceIdentification(DEVICE_IDENTIFICATION).withObject(requestMessage).build();
    this.device = new Device(DEVICE_IDENTIFICATION);
    when(this.deviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(this.device);
    when(this.deviceRepository.save(this.device)).thenAnswer((Answer<Void>) invocationOnMock -> null);
    doNothing().when(this.eventNotificationMessageService).handleEvent(any(String.class), any(Date.class), any(EventType.class), any(String.class), any(Integer.class));
    when(this.deviceAuthorizationRepository.findByDeviceAndFunctionGroup(this.device, DeviceFunctionGroup.OWNER)).thenReturn(Collections.singletonList(this.deviceAuthorization));
    when(this.deviceAuthorization.getOrganisation()).thenReturn(this.organisation);
    when(this.organisation.getOrganisationIdentification()).thenReturn(requestMessage.getOrganisationIdentification());
    when(this.domainInfoRepository.findAll()).thenReturn(Collections.singletonList(this.domainInfo));
    when(this.domainInfo.getDomain()).thenReturn("SMART_METERING");
    when(this.domainInfo.getDomainVersion()).thenReturn("1.0");
    doNothing().when(this.domainRequestService).send(any(RequestMessage.class), any(String.class), any(DomainInfo.class));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Strictness(org.mockito.quality.Strictness) BeforeEach(org.junit.jupiter.api.BeforeEach) DeviceAuthorizationRepository(org.opensmartgridplatform.domain.core.repositories.DeviceAuthorizationRepository) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) DeviceAuthorization(org.opensmartgridplatform.domain.core.entities.DeviceAuthorization) Date(java.util.Date) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EventType(org.opensmartgridplatform.domain.core.valueobjects.EventType) ObjectMessage(javax.jms.ObjectMessage) MessageType(org.opensmartgridplatform.shared.infra.jms.MessageType) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Answer(org.mockito.stubbing.Answer) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) DomainRequestService(org.opensmartgridplatform.core.domain.model.domain.DomainRequestService) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo) DeviceRepository(org.opensmartgridplatform.domain.core.repositories.DeviceRepository) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) JMSException(javax.jms.JMSException) EventNotificationMessageService(org.opensmartgridplatform.core.application.services.EventNotificationMessageService) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) UnknownEntityException(org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException) PushNotificationAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto) Device(org.opensmartgridplatform.domain.core.entities.Device) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) DomainInfoRepository(org.opensmartgridplatform.domain.core.repositories.DomainInfoRepository) DeviceFunctionGroup(org.opensmartgridplatform.domain.core.valueobjects.DeviceFunctionGroup) Collections(java.util.Collections) EventType(org.opensmartgridplatform.domain.core.valueobjects.EventType) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo) Date(java.util.Date) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class SystemEventMessageProcessorTest method init.

@BeforeEach
public void init() throws JMSException {
    final String correlationUid = "corr-uid-1";
    final String organisationIdentification = "test-org";
    final String ipAddress = "127.0.0.1";
    final String domain = "SMART_METERING";
    final String domainVersion = "1.0";
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisationIdentification, DEVICE_IDENTIFICATION, ipAddress, null, null, this.systemEventDto);
    this.message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withMessageType(MessageType.SYSTEM_EVENT.name()).withDeviceIdentification(DEVICE_IDENTIFICATION).withObject(requestMessage).build();
    this.message.setStringProperty(Constants.DOMAIN, domain);
    this.message.setStringProperty(Constants.DOMAIN_VERSION, domainVersion);
    when(this.domainInfoRepository.findByDomainAndDomainVersion(domain, domainVersion)).thenReturn(this.domainInfo);
    doNothing().when(this.domainRequestService).send(any(RequestMessage.class), any(String.class), any(DomainInfo.class));
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)17 ObjectMessage (javax.jms.ObjectMessage)15 Test (org.junit.jupiter.api.Test)12 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)9 UpdateFirmwareRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto)6 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)6 FirmwareFileDto (org.opensmartgridplatform.dto.valueobjects.FirmwareFileDto)4 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)4 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)4 When (io.cucumber.java.en.When)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Date (java.util.Date)2 DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)2 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)2 DomainInfo (org.opensmartgridplatform.domain.core.entities.DomainInfo)2 ConnectRequestDto (org.opensmartgridplatform.dto.da.ConnectRequestDto)2 GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)2 Collections (java.util.Collections)1 JMSException (javax.jms.JMSException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1