Search in sources :

Example 6 with SmartMeteringDevice

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice in project open-smart-grid-platform by OSGP.

the class SmartMeterService method storeMeter.

public void storeMeter(final String organisationIdentification, final AddSmartMeterRequest addSmartMeterRequest, SmartMeter smartMeter) throws FunctionalException {
    final SmartMeteringDevice smartMeteringDevice = addSmartMeterRequest.getDevice();
    smartMeter.updateProtocol(this.getProtocolInfo(smartMeteringDevice));
    smartMeter.setDeviceModel(this.getDeviceModel(addSmartMeterRequest.getDeviceModel()));
    smartMeter = this.smartMeterRepository.save(smartMeter);
    this.storeAuthorization(organisationIdentification, smartMeter);
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)

Example 7 with SmartMeteringDevice

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method createSmartMeteringDevice.

/**
 * Method to create an instance of SmartMeteringDevice.
 */
private SmartMeteringDevice createSmartMeteringDevice() {
    final SmartMeteringDevice smartMeteringDevice = new SmartMeteringDevice();
    smartMeteringDevice.setDeviceIdentification(DEVICE_IDENTIFICATION);
    smartMeteringDevice.setDeviceType(DEVICE_TYPE);
    smartMeteringDevice.setCommunicationMethod(COMMUNICATION_METHOD);
    smartMeteringDevice.setCommunicationProvider(COMMUNICATION_PROVIDER);
    smartMeteringDevice.setIccId(ICC_ID);
    smartMeteringDevice.setProtocolName(PROTOCOL_NAME);
    smartMeteringDevice.setProtocolVersion(PROTOCOL_VERSION);
    smartMeteringDevice.setSupplier(SUPPLIER);
    smartMeteringDevice.setHls3Active(IS_ACTIVE);
    smartMeteringDevice.setHls4Active(IS_ACTIVE);
    smartMeteringDevice.setHls5Active(IS_ACTIVE);
    smartMeteringDevice.setMasterKey(KEY);
    smartMeteringDevice.setGlobalEncryptionUnicastKey(KEY);
    smartMeteringDevice.setAuthenticationKey(KEY);
    smartMeteringDevice.setDeliveryDate(this.deliveryDateSmartMeteringDevice);
    return smartMeteringDevice;
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)

Example 8 with SmartMeteringDevice

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method testSmartMeteringDeviceMapping.

/**
 * Test to see if a SmartMeteringDevice can be mapped to a Device
 */
@Test
public void testSmartMeteringDeviceMapping() {
    // build test data
    final SmartMeteringDevice smartMeteringDevice = this.createSmartMeteringDevice();
    // actual mapping
    final Device device = this.installationMapper.map(smartMeteringDevice, Device.class);
    // check mapping
    this.checkSmartMeteringDeviceToDeviceMapping(device);
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Test(org.junit.jupiter.api.Test)

Example 9 with SmartMeteringDevice

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method testDeviceMapping.

/**
 * Test to see if a Device object can be mapped to a SmartMeteringDevice object
 */
@Test
public void testDeviceMapping() {
    // build test data
    final Device device = this.createDevice();
    // actual mapping
    final SmartMeteringDevice smartMeteringDevice = this.installationMapper.map(device, SmartMeteringDevice.class);
    // check mapping
    this.checkDeviceToSmartMeteringDeviceMapping(smartMeteringDevice);
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Test(org.junit.jupiter.api.Test)

Example 10 with SmartMeteringDevice

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice in project open-smart-grid-platform by OSGP.

the class SmartMeterServiceTest method testStoreMeterWithUnknownProtocolInfo.

@Test
void testStoreMeterWithUnknownProtocolInfo() {
    final String organisationIdentification = "org-1";
    final SmartMeteringDevice smartMeteringDevice = new SmartMeteringDevice();
    final DeviceModel deviceModel = new DeviceModel();
    final AddSmartMeterRequest addSmartMeterRequest = new AddSmartMeterRequest(smartMeteringDevice, deviceModel);
    final SmartMeter smartMeter = new SmartMeter();
    when(this.protocolInfoRepository.findByProtocolAndProtocolVersion(any(), any())).thenReturn(null);
    FunctionalException exception = Assertions.assertThrows(FunctionalException.class, () -> {
        this.smartMeterService.storeMeter(organisationIdentification, addSmartMeterRequest, smartMeter);
    });
    assertThat(exception.getExceptionType()).isEqualTo(FunctionalExceptionType.UNKNOWN_PROTOCOL_NAME_OR_VERSION);
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.valueobjects.DeviceModel) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) AddSmartMeterRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AddSmartMeterRequest) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Aggregations

SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)10 Test (org.junit.jupiter.api.Test)6 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)4 DeviceModel (org.opensmartgridplatform.domain.core.valueobjects.DeviceModel)3 AddSmartMeterRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AddSmartMeterRequest)3 Date (java.util.Date)2 Device (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device)2 SmartMeteringDeviceDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto)2 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 ConstraintViolationException (javax.validation.ConstraintViolationException)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse)1 AddDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.AddDeviceAsyncResponse)1 CoupleMbusDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceAsyncResponse)1 CoupleMbusDeviceByChannelAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceByChannelAsyncResponse)1 DecoupleMbusDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceAsyncResponse)1 DecoupleMbusDeviceByChannelAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.DecoupleMbusDeviceByChannelAsyncResponse)1 Manufacturer (org.opensmartgridplatform.domain.core.entities.Manufacturer)1 ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1