use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithFilledSet.
/**
* Test to see if an AlarmRegister object is mapped correctly with a filled Set.
*/
@Test
public void testWithFilledSet() {
// build test data
final Set<AlarmType> alarmTypeSet = new TreeSet<>();
alarmTypeSet.add(ALARMTYPE);
final AlarmRegister original = new AlarmRegister(alarmTypeSet);
// actual mapping
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister mapped = this.monitoringMapper.map(original, org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getAlarmTypes()).isNotNull();
assertThat(mapped.getAlarmTypes().get(0)).isNotNull();
assertThat(mapped.getAlarmTypes().size()).isEqualTo(original.getAlarmTypes().size());
assertThat(mapped.getAlarmTypes().get(0).name()).isEqualTo(ALARMTYPE.name());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister in project open-smart-grid-platform by OSGP.
the class MonitoringService method handleReadAlarmRegisterResponse.
public void handleReadAlarmRegisterResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final AlarmRegisterResponseDto alarmRegisterDto) {
LOGGER.info("handleReadAlarmRegisterResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
result = ResponseMessageResultType.NOT_OK;
}
final AlarmRegister alarmRegisterValueDomain = this.monitoringMapper.map(alarmRegisterDto, AlarmRegister.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(alarmRegisterValueDomain).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithEmptySet.
// Test if mapping with an empty set succeeds
@Test
public void testWithEmptySet() {
// build test data
final Set<AlarmTypeDto> alarmTypes = new TreeSet<>();
final AlarmRegisterResponseDto alarmRegisterDto = new AlarmRegisterResponseDto(alarmTypes);
// actual mapping
final AlarmRegister alarmRegister = this.monitoringMapper.map(alarmRegisterDto, AlarmRegister.class);
// test mapping
assertThat(alarmRegister).isNotNull();
assertThat(alarmRegister.getAlarmTypes()).isEmpty();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithNonEmptySet.
// Test if mapping with a non-empty set succeeds
@Test
public void testWithNonEmptySet() {
// build test data
final Set<AlarmTypeDto> alarmTypes = new TreeSet<>();
alarmTypes.add(AlarmTypeDto.CLOCK_INVALID);
final AlarmRegisterResponseDto alarmRegisterDto = new AlarmRegisterResponseDto(alarmTypes);
// actual mapping
final AlarmRegister alarmRegister = this.monitoringMapper.map(alarmRegisterDto, AlarmRegister.class);
// test mapping
assertThat(alarmRegister).isNotNull();
assertThat(alarmRegister.getAlarmTypes().size()).isEqualTo(alarmRegisterDto.getAlarmTypes().size());
assertThat(alarmRegister.getAlarmTypes().contains(AlarmType.CLOCK_INVALID)).isTrue();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithEmptySet.
/**
* Test to see if an AlarmRegister object is mapped correctly with an empty Set.
*/
@Test
public void testWithEmptySet() {
// build test data
final Set<AlarmType> alarmTypeSet = new TreeSet<>();
final AlarmRegister original = new AlarmRegister(alarmTypeSet);
// actual mapping
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister mapped = this.monitoringMapper.map(original, org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getAlarmTypes()).isNotNull();
assertThat(mapped.getAlarmTypes().isEmpty()).isTrue();
}
Aggregations