use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithLists.
// To test Mapping if lists contain values
@Test
public void testPushSetupSmsMappingWithLists() {
// build test data
final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final WindowElement windowElement = new WindowElement(startTime, endTime);
final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
this.checkNonEmptyListMapping(pushSetupSms, pushSetupSmsDto);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingNull.
// To test if a PushSetupAlarm can be mapped if instance variables are
// null.
@Test
public void testPushSetupSmsMappingNull() {
// build test data
final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withNullValues().build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
assertThat(pushSetupSmsDto).isNotNull();
assertThat(pushSetupSmsDto.getLogicalName()).isNull();
assertThat(pushSetupSmsDto.getPushObjectList()).isNull();
assertThat(pushSetupSmsDto.getSendDestinationAndMethod()).isNull();
assertThat(pushSetupSmsDto.getCommunicationWindow()).isNull();
assertThat(pushSetupSmsDto.getRandomisationStartInterval()).isNull();
assertThat(pushSetupSmsDto.getNumberOfRetries()).isNull();
assertThat(pushSetupSmsDto.getRepetitionDelay()).isNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms in project open-smart-grid-platform by OSGP.
the class PushSetupSmsConverter method convertTo.
@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms convertTo(final PushSetupSms source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
if (!source.hasSendDestinationAndMethod()) {
throw new IllegalArgumentException("Unable to map PushSetup Sms without SendDestinationAndMethod.");
}
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(":");
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms pushSetup = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms();
pushSetup.setHost(hostAndPort[0]);
pushSetup.setPort(new BigInteger(hostAndPort[1]));
return pushSetup;
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms in project open-smart-grid-platform by OSGP.
the class SetPushSetupSmsRequestMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) throws FunctionalException {
final PushSetupSms pushSetupSms = (PushSetupSms) dataObject;
this.configurationService.setPushSetupSms(deviceMessageMetadata, pushSetupSms);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithEmptyLists.
// To test if a PushSetupAlarm can be mapped if instance variables are
// initialized and lists are empty.
@Test
public void testPushSetupSmsMappingWithEmptyLists() {
// build test data
final ArrayList<CosemObjectDefinition> pushObjectList = new ArrayList<>();
final ArrayList<WindowElement> communicationWindow = new ArrayList<>();
final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withEmptyLists(pushObjectList, communicationWindow).build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
assertThat(pushSetupSmsDto.getPushObjectList()).isNotNull();
assertThat(pushSetupSmsDto.getCommunicationWindow()).isNotNull();
}
Aggregations