use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmDtoConverterTest method convertTestWithEmptyLists.
@Test
void convertTestWithEmptyLists() {
when(this.pushSetupAlarm.getCommunicationWindow()).thenReturn(null);
when(this.pushSetupAlarm.getPushObjectList()).thenReturn(null);
final PushSetupAlarmDto result = this.pushSetupAlarmDtoConverter.convert(this.pushSetupAlarm, null, this.mappingContext);
assertThat(result.getCommunicationWindow()).isNull();
assertThat(result.getPushObjectList()).isNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class ConfigurationService method setPushSetupAlarm.
public void setPushSetupAlarm(final MessageMetadata messageMetadata, final PushSetupAlarm pushSetupAlarm) throws FunctionalException {
log.info("setPushSetupAlarm for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
final PushSetupAlarmDto requestDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto 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.dto.valueobjects.smartmetering.PushSetupAlarmDto 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.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetWithUnsupportedFieldsSet.
@Test
void testSetWithUnsupportedFieldsSet() {
// SETUP
final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withCommunicationWindow(new ArrayList<>()).build();
// CALL
final Throwable thrown = catchThrowable(() -> {
this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
});
// VERIFY
assertThat(thrown).isInstanceOf(ProtocolAdapterException.class);
}
Aggregations