use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class AddressConversionTest method shouldConvertWsAddressToAddress.
@Test
public void shouldConvertWsAddressToAddress() {
// Arrange
final org.opensmartgridplatform.adapter.ws.schema.core.common.Address source = this.createWsAddress();
final Address expected = this.createAddress();
// Act
final Address actual = this.mapper.map(source, Address.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class AddressConversionTest method shouldMapNullValue.
@Test
public void shouldMapNullValue() {
// Arrange
final org.opensmartgridplatform.adapter.ws.schema.core.common.Address source = null;
final Address expected = null;
// Act
final Address actual = this.mapper.map(source, Address.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class DeviceConverterTest method testSmartMeterConversion.
@Test
public void testSmartMeterConversion() throws UnknownHostException {
final Device device = new SmartMeter("id", "alias", new Address("city", "postal", "street", 42, "nr", "munic"), new GpsCoordinates(12f, 13f));
device.updateRegistrationData(InetAddress.getByName("localhost"), "type");
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device jaxbDevice = this.deviceManagementMapper.map(device, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device.class);
assertThat(jaxbDevice.getDeviceIdentification()).isEqualTo("id");
assertThat(jaxbDevice.getAlias()).isEqualTo("alias");
assertThat(jaxbDevice.getContainerAddress().getCity()).isEqualTo("city");
assertThat(jaxbDevice.getContainerAddress().getPostalCode()).isEqualTo("postal");
assertThat(jaxbDevice.getContainerAddress().getStreet()).isEqualTo("street");
assertThat(jaxbDevice.getContainerAddress().getNumber()).isEqualTo(new Integer(42));
assertThat(jaxbDevice.getContainerAddress().getNumberAddition()).isEqualTo("nr");
assertThat(jaxbDevice.getContainerAddress().getMunicipality()).isEqualTo("munic");
assertThat(jaxbDevice.getGpsLatitude()).isEqualTo("12.0");
assertThat(jaxbDevice.getGpsLongitude()).isEqualTo("13.0");
assertThat(jaxbDevice.getNetworkAddress()).isEqualTo("localhost/127.0.0.1");
assertThat(jaxbDevice.getDeviceType()).isEqualTo("type");
final SmartMeter mappedBack = this.deviceManagementMapper.map(jaxbDevice, SmartMeter.class);
assertThat(mappedBack.getDeviceIdentification()).isEqualTo("id");
assertThat(mappedBack.getAlias()).isEqualTo("alias");
assertThat(mappedBack.getContainerAddress().getCity()).isEqualTo("city");
assertThat(mappedBack.getContainerAddress().getPostalCode()).isEqualTo("postal");
assertThat(mappedBack.getContainerAddress().getStreet()).isEqualTo("street");
assertThat(mappedBack.getContainerAddress().getNumber()).isEqualTo(new Integer(42));
assertThat(mappedBack.getContainerAddress().getNumberAddition()).isEqualTo("nr");
assertThat(mappedBack.getContainerAddress().getMunicipality()).isEqualTo("munic");
assertThat(mappedBack.getGpsCoordinates().getLatitude()).isEqualTo(12);
assertThat(mappedBack.getGpsCoordinates().getLongitude()).isEqualTo(13);
// alas networkaddress in jaxb device is just a string, need parsing to
// convert that to InetAddress
assertThat(mappedBack.getNetworkAddress()).isEqualTo(null);
assertThat(mappedBack.getDeviceType()).isEqualTo("type");
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class DeviceConverterTest method testDeviceConversion.
@Test
public void testDeviceConversion() throws UnknownHostException {
final Device device = new Device("id", "alias", new Address("city", "postal", "street", 42, "nr", "munic"), new GpsCoordinates(12f, 13f), null);
device.updateRegistrationData(InetAddress.getByName("localhost"), "type");
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device jaxbDevice = this.deviceManagementMapper.map(device, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device.class);
assertThat(jaxbDevice.getDeviceIdentification()).isEqualTo("id");
assertThat(jaxbDevice.getAlias()).isEqualTo("alias");
assertThat(jaxbDevice.getContainerAddress().getCity()).isEqualTo("city");
assertThat(jaxbDevice.getContainerAddress().getPostalCode()).isEqualTo("postal");
assertThat(jaxbDevice.getContainerAddress().getStreet()).isEqualTo("street");
assertThat(jaxbDevice.getContainerAddress().getNumber()).isEqualTo(new Integer(42));
assertThat(jaxbDevice.getContainerAddress().getNumberAddition()).isEqualTo("nr");
assertThat(jaxbDevice.getContainerAddress().getMunicipality()).isEqualTo("munic");
assertThat(jaxbDevice.getGpsLatitude()).isEqualTo("12.0");
assertThat(jaxbDevice.getGpsLongitude()).isEqualTo("13.0");
assertThat(jaxbDevice.getNetworkAddress()).isEqualTo("localhost/127.0.0.1");
assertThat(jaxbDevice.getDeviceType()).isEqualTo("type");
final Device mappedBack = this.deviceManagementMapper.map(jaxbDevice, Device.class);
assertThat(mappedBack.getDeviceIdentification()).isEqualTo("id");
assertThat(mappedBack.getAlias()).isEqualTo("alias");
assertThat(mappedBack.getContainerAddress().getCity()).isEqualTo("city");
assertThat(mappedBack.getContainerAddress().getPostalCode()).isEqualTo("postal");
assertThat(mappedBack.getContainerAddress().getStreet()).isEqualTo("street");
assertThat(mappedBack.getContainerAddress().getNumber()).isEqualTo(new Integer(42));
assertThat(mappedBack.getContainerAddress().getNumberAddition()).isEqualTo("nr");
assertThat(mappedBack.getContainerAddress().getMunicipality()).isEqualTo("munic");
assertThat(mappedBack.getGpsCoordinates().getLatitude()).isEqualTo(12);
assertThat(mappedBack.getGpsCoordinates().getLongitude()).isEqualTo(13);
// alas networkaddress in jaxb device is just a string, need parsing to
// convert that to InetAddress
assertThat(mappedBack.getNetworkAddress()).isEqualTo(null);
assertThat(mappedBack.getDeviceType()).isEqualTo("type");
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class LmdConverter method convertFrom.
@Override
public org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice convertFrom(final LightMeasurementDevice source, final Type<org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice> destinationType, final MappingContext mappingContext) {
final String deviceIdentification = source.getDeviceIdentification();
final Integer containerNumber = source.getContainerNumber() == null ? null : Integer.valueOf(source.getContainerNumber());
final Address containerAddress = new Address(source.getContainerCity(), source.getContainerPostalCode(), source.getContainerStreet(), containerNumber, null, null);
final GpsCoordinates gpsCoordinates = new GpsCoordinates(source.getGpsLatitude(), source.getGpsLongitude());
final org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice lmd = new org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice(deviceIdentification, null, containerAddress, gpsCoordinates, null);
lmd.updateRegistrationData(null, source.getDeviceType());
lmd.setDescription(source.getDescription());
lmd.setCode(source.getCode());
lmd.setColor(source.getColor());
lmd.setDigitalInput(source.getDigitalInput());
return lmd;
}
Aggregations