use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingNull.
// To test if a PushSetupAlarm can be mapped if instance variables are null.
@Test
public void testPushSetupAlarmMappingNull() {
// build test data
final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withNullValues().build();
// actual mapping
final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
// check values
assertThat(pushSetupAlarmDto).isNotNull();
assertThat(pushSetupAlarmDto.getLogicalName()).isNull();
assertThat(pushSetupAlarmDto.getPushObjectList()).isNull();
assertThat(pushSetupAlarmDto.getSendDestinationAndMethod()).isNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNull();
assertThat(pushSetupAlarmDto.getRandomisationStartInterval()).isNull();
assertThat(pushSetupAlarmDto.getNumberOfRetries()).isNull();
assertThat(pushSetupAlarmDto.getRepetitionDelay()).isNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithEmptyLists.
// To test if a PushSetupAlarm can be mapped if instance variables are
// initialized and lists are empty.
@Test
public void testPushSetupAlarmMappingWithEmptyLists() {
// build test data
final ArrayList<CosemObjectDefinition> pushObjectList = new ArrayList<>();
final ArrayList<WindowElement> communicationWindow = new ArrayList<>();
final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withEmptyLists(pushObjectList, communicationWindow).build();
// actual mapping
final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupAlarm.getLogicalName(), pushSetupAlarmDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupAlarm, pushSetupAlarmDto);
this.checkIntegerMapping(pushSetupAlarm, pushSetupAlarmDto);
assertThat(pushSetupAlarmDto.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNotNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmConverter method convertTo.
@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm convertTo(final PushSetupAlarm source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm pushSetupAlarm = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm();
if (source.hasSendDestinationAndMethod()) {
final SendDestinationAndMethod sendDestinationAndMethod = source.getSendDestinationAndMethod();
final String destination = sendDestinationAndMethod.getDestination();
if (!destination.matches("\\S++:\\d++")) {
throw new IllegalArgumentException("Unable to parse destination as \"<host>:<port>\": " + destination);
}
final String[] hostAndPort = destination.split(":");
pushSetupAlarm.setHost(hostAndPort[0]);
pushSetupAlarm.setPort(new BigInteger(hostAndPort[1]));
}
if (source.hasPushObjectList()) {
final List<PushObject> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), PushObject.class);
pushSetupAlarm.getPushObjectList().addAll(convertedPushObjectList);
}
return pushSetupAlarm;
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmRequestMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) throws FunctionalException {
final PushSetupAlarm pushSetupAlarm = (PushSetupAlarm) dataObject;
this.configurationService.setPushSetupAlarm(deviceMessageMetadata, pushSetupAlarm);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmConverter method convertFrom.
@Override
public PushSetupAlarm convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm source, final Type<PushSetupAlarm> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final PushSetupAlarm.Builder builder = new PushSetupAlarm.Builder();
if (source.getHost() != null && source.getPort() != null) {
final String destination = source.getHost() + ":" + source.getPort();
final SendDestinationAndMethod sendDestinationAndMethod = new SendDestinationAndMethod(TransportServiceType.TCP, destination, MessageType.A_XDR_ENCODED_X_DLMS_APDU);
builder.withSendDestinationAndMethod(sendDestinationAndMethod);
}
final List<PushObject> sourcePushObjects = source.getPushObjectList();
if (sourcePushObjects != null) {
final List<CosemObjectDefinition> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), CosemObjectDefinition.class);
builder.withPushObjectList(convertedPushObjectList);
}
return builder.build();
}
Aggregations