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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations