Search in sources :

Example 1 with SmartMeteringDeviceDto

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

the class InstallationServiceTest method addMeterNoKeys.

@Test
void addMeterNoKeys() {
    // GIVEN
    final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
    deviceDto.setDeviceIdentification(this.deviceIdentification);
    // WHEN
    Assertions.assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.testService.addMeter(this.messageMetadata, deviceDto));
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Example 2 with SmartMeteringDeviceDto

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

the class DeviceConverterTest method convertsSmartMeteringDtoToDlmsDevice.

@Test
public void convertsSmartMeteringDtoToDlmsDevice() {
    final SmartMeteringDeviceDto dto = new SmartMeteringDeviceDtoBuilder().build();
    final DlmsDevice result = this.converter.convertTo(dto, null, null);
    final DlmsDevice expected = this.converted(dto);
    Assertions.assertThat(result).isEqualToIgnoringGivenFields(expected, "creationTime", "modificationTime", "version");
}
Also used : SmartMeteringDeviceDtoBuilder(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDtoBuilder) SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Example 3 with SmartMeteringDeviceDto

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

the class InstallationMapperTest method testSmartMeteringDeviceToSmartMeteringDeviceDtoMapping.

@Test
public void testSmartMeteringDeviceToSmartMeteringDeviceDtoMapping() {
    final SmartMeteringDevice smartMeteringDevice = new SmartMeteringDevice();
    smartMeteringDevice.setDeviceIdentification("device1");
    smartMeteringDevice.setDeviceType("typeA");
    smartMeteringDevice.setCommunicationMethod("skype");
    smartMeteringDevice.setCommunicationProvider("theInternet");
    smartMeteringDevice.setIccId("value");
    smartMeteringDevice.setProtocolName("protocolName");
    smartMeteringDevice.setProtocolVersion("latestVersion");
    smartMeteringDevice.setMasterKey("masterKey".getBytes());
    smartMeteringDevice.setGlobalEncryptionUnicastKey("globalEncryptionUnicastKey".getBytes());
    smartMeteringDevice.setAuthenticationKey("authenticationKey".getBytes());
    smartMeteringDevice.setSupplier("supplier");
    smartMeteringDevice.setHls3Active(true);
    smartMeteringDevice.setHls4Active(true);
    smartMeteringDevice.setHls5Active(true);
    smartMeteringDevice.setDeliveryDate(new Date());
    smartMeteringDevice.setMbusIdentificationNumber("12345678");
    smartMeteringDevice.setMbusManufacturerIdentification("XYZ");
    smartMeteringDevice.setMbusVersion((short) 112);
    smartMeteringDevice.setMbusDeviceTypeIdentification((short) 3);
    smartMeteringDevice.setMbusDefaultKey("mbusDefaultKey".getBytes());
    final SmartMeteringDeviceDto smartMeteringDeviceDto = this.mapperFactory.getMapperFacade().map(smartMeteringDevice, SmartMeteringDeviceDto.class);
    assertThat(smartMeteringDevice).isNotNull();
    assertThat(smartMeteringDeviceDto).isNotNull();
    assertThat(smartMeteringDeviceDto).isEqualToIgnoringGivenFields(smartMeteringDevice, "hls3Active", "hls4Active", "hls5Active");
    assertThat(smartMeteringDeviceDto.isHls3Active()).isEqualTo(smartMeteringDevice.isHls3Active());
    assertThat(smartMeteringDeviceDto.isHls4Active()).isEqualTo(smartMeteringDevice.isHls4Active());
    assertThat(smartMeteringDeviceDto.isHls5Active()).isEqualTo(smartMeteringDevice.isHls5Active());
    assertThat(smartMeteringDeviceDto).isNotNull().isEqualToIgnoringGivenFields(smartMeteringDevice, "ipAddress", "btsId", "cellId");
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 4 with SmartMeteringDeviceDto

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

the class InstallationService method addMeter.

public void addMeter(final MessageMetadata messageMetadata, final AddSmartMeterRequest addSmartMeterRequest) throws FunctionalException {
    final String organisationId = messageMetadata.getOrganisationIdentification();
    final String deviceId = messageMetadata.getDeviceIdentification();
    LOGGER.debug("addMeter for organisationIdentification: {} for deviceIdentification: {}", organisationId, deviceId);
    final SmartMeteringDevice smartMeteringDevice = addSmartMeterRequest.getDevice();
    final String deviceIdentification = messageMetadata.getDeviceIdentification();
    this.smartMeterService.validateSmartMeterDoesNotExist(deviceIdentification);
    final SmartMeter smartMeter = this.smartMeterService.convertSmartMeter(smartMeteringDevice);
    this.smartMeterService.storeMeter(organisationId, addSmartMeterRequest, smartMeter);
    final SmartMeteringDeviceDto requestDto = this.mapperFactory.getMapperFacade().map(smartMeteringDevice, SmartMeteringDeviceDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata);
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter)

Example 5 with SmartMeteringDeviceDto

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

the class InstallationServiceTest method addMeterNoDeviceIdentification.

@Test
void addMeterNoDeviceIdentification() {
    // GIVEN
    final SmartMeteringDeviceDto deviceDto = new SmartMeteringDeviceDto();
    deviceDto.setMbusDefaultKey(new byte[16]);
    // WHEN
    Assertions.assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.testService.addMeter(this.messageMetadata, deviceDto));
}
Also used : SmartMeteringDeviceDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Aggregations

SmartMeteringDeviceDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto)9 Test (org.junit.jupiter.api.Test)7 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)3 SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)2 Date (java.util.Date)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 SmartMeteringDeviceDtoBuilder (org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDtoBuilder)1