Search in sources :

Example 1 with AlarmType

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType 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 AlarmType

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

the class PushNotificationAlarmMappingTest method testPushNotificiationAlarmMappingWithNullSet.

/**
 * Tests if mapping a PushNotificationAlarm object succeeds with a null Set.
 */
@Test
void testPushNotificiationAlarmMappingWithNullSet() {
    // build test data
    final Set<AlarmType> alarms = null;
    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.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    // constructor for PushNotificationAlarm creates a new Set when passed a
    // null value, so we should check for an empty List
    assertThat(mapped.getAlarmRegister()).isNotNull();
    assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotNull();
    assertThat(mapped.getAlarmRegister().getAlarmTypes().isEmpty()).isTrue();
}
Also used : PushNotificationAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) RetrievePushNotificationAlarmResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse) Test(org.junit.jupiter.api.Test)

Example 3 with AlarmType

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

the class AlarmNotificationsConverter method convertFrom.

@Override
public AlarmNotifications convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications source, final Type<AlarmNotifications> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final Set<AlarmNotification> alarmNotifications = new TreeSet<AlarmNotification>();
    final List<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification> sourceNotifications = source.getAlarmNotification();
    for (final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification sourceNotification : sourceNotifications) {
        final AlarmType alarmType = AlarmType.valueOf(sourceNotification.getAlarmType().name());
        final boolean enabled = sourceNotification.isEnabled();
        alarmNotifications.add(new AlarmNotification(alarmType, enabled));
    }
    return new AlarmNotifications(alarmNotifications);
}
Also used : AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) AlarmType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType) TreeSet(java.util.TreeSet) AlarmNotification(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification)

Example 4 with AlarmType

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType 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 5 with AlarmType

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType 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)

Aggregations

AlarmType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType)6 TreeSet (java.util.TreeSet)5 Test (org.junit.jupiter.api.Test)5 RetrievePushNotificationAlarmResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse)3 PushNotificationAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm)3 AlarmRegister (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister)2 AlarmNotification (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification)1 AlarmNotifications (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications)1