Search in sources :

Example 1 with GetPowerQualityProfileRequestDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileDataMapperTest method shouldConvertValueObjectToDto.

@Test
public void shouldConvertValueObjectToDto() {
    final GetPowerQualityProfileRequestData source = new GetPowerQualityProfileRequestData("PUBLIC", BEGIN_DATE.toDate(), END_DATE.toDate());
    final GetPowerQualityProfileRequestDataDto result = this.mapper.map(source, GetPowerQualityProfileRequestDataDto.class);
    assertThat(result.getBeginDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(BEGIN_DATE.toDate());
    assertThat(result.getEndDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(END_DATE.toDate());
}
Also used : GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with GetPowerQualityProfileRequestDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.

the class DeviceRequestMessageListenerIT method testProcessRequestMessages.

@Test
void testProcessRequestMessages() throws JMSException, OsgpException {
    // SETUP
    final DlmsDevice dlmsDevice = new DlmsDevice();
    dlmsDevice.setDeviceIdentification("1");
    dlmsDevice.setIpAddress("127.0.0.1");
    dlmsDevice.setHls5Active(true);
    when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(dlmsDevice);
    doNothing().when(this.protocolDlmsOutboundOsgpCoreResponsesMessageSender).send(any(ResponseMessage.class));
    // EXECUTE
    LOGGER.info("Starting Test");
    for (int i = 0; i < 200; i++) {
        LOGGER.info("Send message number {} ", i);
        final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification("osgp").withMessageType(MessageType.GET_PROFILE_GENERIC_DATA.toString()).withObject(new GetPowerQualityProfileRequestDataDto("PUBLIC", new Date(), new Date(), null)).build();
        this.listener.onMessage(message);
    }
    verify(this.protocolDlmsOutboundOsgpCoreResponsesMessageSender, times(200)).send(any(ResponseMessage.class));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ObjectMessage(javax.jms.ObjectMessage) GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) Date(java.util.Date) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with GetPowerQualityProfileRequestDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileNoSelectiveAccessHandlerTest method testHandlePublicProfileWithoutSelectiveAccess.

@Test
public void testHandlePublicProfileWithoutSelectiveAccess() throws ProtocolAdapterException {
    // SETUP
    final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PUBLIC", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
    when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries(), this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries());
    when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
    when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
    when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
    final GetPowerQualityProfileNoSelectiveAccessHandler handler = new GetPowerQualityProfileNoSelectiveAccessHandler(this.dlmsHelper);
    // EXECUTE
    final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
    // ASSERT
    assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
    for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
        assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(2);
    }
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 4 with GetPowerQualityProfileRequestDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileSelectiveAccessHandlerTest method testHandlePrivateProfileSelectiveAccess.

@Test
public void testHandlePrivateProfileSelectiveAccess() throws ProtocolAdapterException {
    // SETUP
    final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PRIVATE", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
    when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createCaptureObjects(), this.createProfileEntries(), this.createCaptureObjectsProfile2(), this.createProfileEntries());
    when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
    when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
    when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
    final GetPowerQualityProfileSelectiveAccessHandler handler = new GetPowerQualityProfileSelectiveAccessHandler(this.dlmsHelper);
    // EXECUTE
    final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
    // ASSERT
    assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(3);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
    for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
        assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(3);
    }
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 5 with GetPowerQualityProfileRequestDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(GetPowerQualityProfileRequestDataDto.class, requestObject);
    final GetPowerQualityProfileRequestDataDto getPowerQualityProfileRequestDataDto = (GetPowerQualityProfileRequestDataDto) requestObject;
    return this.monitoringService.requestPowerQualityProfile(conn, device, getPowerQualityProfileRequestDataDto, messageMetadata);
}
Also used : GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto)

Aggregations

GetPowerQualityProfileRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto)5 Test (org.junit.jupiter.api.Test)4 Date (java.util.Date)3 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)2 GetPowerQualityProfileResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)2 ProfileEntryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto)2 ObjectMessage (javax.jms.ObjectMessage)1 GetPowerQualityProfileRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1