Search in sources :

Example 1 with AlarmRegister

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());
}
Also used : TreeSet(java.util.TreeSet) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) Test(org.junit.jupiter.api.Test)

Example 2 with AlarmRegister

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());
}
Also used : AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

Example 3 with AlarmRegister

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();
}
Also used : AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) TreeSet(java.util.TreeSet) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto) Test(org.junit.jupiter.api.Test)

Example 4 with AlarmRegister

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();
}
Also used : AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) TreeSet(java.util.TreeSet) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto) Test(org.junit.jupiter.api.Test)

Example 5 with AlarmRegister

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();
}
Also used : TreeSet(java.util.TreeSet) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) Test(org.junit.jupiter.api.Test)

Aggregations

AlarmRegister (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister)5 TreeSet (java.util.TreeSet)4 Test (org.junit.jupiter.api.Test)4 AlarmType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType)2 AlarmRegisterResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto)2 AlarmTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto)2 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1