Search in sources :

Example 6 with PushNotificationAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm in project open-smart-grid-platform by OSGP.

the class PushNotificationAlarmMappingTest method testPushNotificationAlarmMappingWithEmptySet.

/**
 * Tests if a PushNotificationAlarm is mapped correctly with an empty Set.
 */
@Test
void testPushNotificationAlarmMappingWithEmptySet() {
    // build test data
    final Set<AlarmType> alarms = new TreeSet<>();
    final PushNotificationAlarm original = new PushNotificationAlarm(DEVICE_ID, alarms, this.alarmBytes);
    // actual mapping
    final RetrievePushNotificationAlarmResponse mapped = this.monitoringMapper.map(original, RetrievePushNotificationAlarmResponse.class);
    // check mapping
    assertThat(mapped).isNotNull();
    assertThat(mapped.getDeviceIdentification()).isNotNull();
    assertThat(mapped.getAlarmRegister()).isNotNull();
    assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotNull();
    assertThat(mapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(mapped.getAlarmRegister().getAlarmTypes().isEmpty()).isTrue();
}
Also used : PushNotificationAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm) TreeSet(java.util.TreeSet) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) RetrievePushNotificationAlarmResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse) Test(org.junit.jupiter.api.Test)

Example 7 with PushNotificationAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm in project open-smart-grid-platform by OSGP.

the class PushNotificationAlarmMappingTest method testPushNotificationAlarmMappingWithFilledSet.

/**
 * Tests if a PushNotificationAlarm object is mapped correctly with a filled Set.
 */
@Test
void testPushNotificationAlarmMappingWithFilledSet() {
    // build test data
    final Set<AlarmType> alarms = new TreeSet<>();
    alarms.add(ALARMTYPE);
    final PushNotificationAlarm original = new PushNotificationAlarm(DEVICE_ID, alarms, this.alarmBytes);
    // actual mapping
    final RetrievePushNotificationAlarmResponse mapped = this.monitoringMapper.map(original, RetrievePushNotificationAlarmResponse.class);
    // check mapping
    assertThat(mapped).isNotNull();
    assertThat(mapped.getDeviceIdentification()).isNotNull();
    assertThat(mapped.getAlarmRegister()).isNotNull();
    assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotEmpty();
    assertThat(mapped.getAlarmRegister().getAlarmTypes().get(0)).isNotNull();
    assertThat(mapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(mapped.getAlarmRegister().getAlarmTypes().get(0).name()).isEqualTo(ALARMTYPE.name());
}
Also used : PushNotificationAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm) TreeSet(java.util.TreeSet) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) RetrievePushNotificationAlarmResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse) Test(org.junit.jupiter.api.Test)

Example 8 with PushNotificationAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm in project open-smart-grid-platform by OSGP.

the class PushNotificationAlarmMappingTest method testWithNonEmptyEnumSet.

// Test if mapping a PushNotificationAlarm object succeeds when the EnumSet
// is not empty
@Test
public void testWithNonEmptyEnumSet() {
    // build test data
    final String deviceId = "device1";
    final EnumSet<AlarmTypeDto> alarms = EnumSet.of(AlarmTypeDto.CLOCK_INVALID);
    final PushNotificationAlarmDto pushNotificationAlarmDto = new PushNotificationAlarmDto(deviceId, alarms, this.alarmBytes);
    // actual mapping
    final PushNotificationAlarm pushNotificationAlarm = this.mapperFactory.getMapperFacade().map(pushNotificationAlarmDto, PushNotificationAlarm.class);
    // test mapping
    assertThat(pushNotificationAlarm).isNotNull();
    assertThat(pushNotificationAlarm.getDeviceIdentification()).isEqualTo(deviceId);
    assertThat(pushNotificationAlarm.getAlarms().size()).isEqualTo(alarms.size());
    assertThat(pushNotificationAlarm.getAlarms().contains(AlarmType.CLOCK_INVALID)).isTrue();
    assertThat(this.alarmBytes).isEqualTo(pushNotificationAlarm.getAlarmBytes());
}
Also used : PushNotificationAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm) AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) PushNotificationAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto) Test(org.junit.jupiter.api.Test)

Aggregations

PushNotificationAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm)8 Test (org.junit.jupiter.api.Test)6 RetrievePushNotificationAlarmResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse)3 AlarmType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType)3 AlarmTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto)3 PushNotificationAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto)3 TreeSet (java.util.TreeSet)2 IOException (java.io.IOException)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)1 GetPushNotificationAlarmResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetPushNotificationAlarmResponse)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1