Search in sources :

Example 1 with AlarmNotifications

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

the class AlarmNotificationsMappingTest method testWithSet.

// Tests if mapping with a Set with an entry succeeds.
@Test
public void testWithSet() {
    // create test data
    final AlarmNotification alarmNotification = new AlarmNotification(AlarmType.CLOCK_INVALID, true);
    final Set<AlarmNotification> alarmNotificationSet = new TreeSet<>();
    alarmNotificationSet.add(alarmNotification);
    final AlarmNotifications alarmNotifications = new AlarmNotifications(alarmNotificationSet);
    // actual mapping
    final AlarmNotificationsDto alarmNotificationsDto = this.configurationMapper.map(alarmNotifications, AlarmNotificationsDto.class);
    // check if mapping was successful
    assertThat(alarmNotificationsDto).isNotNull();
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isNotNull();
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet().size()).isEqualTo(alarmNotificationSet.size());
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet().isEmpty()).isFalse();
    // To see if there is an AlarmNotifictionDto with the same variables as
    // the AlarmNotification in the Set.
    final AlarmNotificationDto alarmNotificationDto = new AlarmNotificationDto(AlarmTypeDto.CLOCK_INVALID, true);
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet().contains(alarmNotificationDto)).isTrue();
}
Also used : AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) AlarmNotificationDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto) TreeSet(java.util.TreeSet) AlarmNotification(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto) Test(org.junit.jupiter.api.Test)

Example 2 with AlarmNotifications

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

the class AlarmNotificationsMappingTest method testWithEmptySet.

// The Set may be empty. Tests if mapping with an empty Set succeeds.
@Test
public void testWithEmptySet() {
    // create test data
    final Set<AlarmNotification> alarmNotificationSet = new TreeSet<>();
    final AlarmNotifications alarmNotifications = new AlarmNotifications(alarmNotificationSet);
    // actual mapping
    final AlarmNotificationsDto alarmNotificationsDto = this.configurationMapper.map(alarmNotifications, AlarmNotificationsDto.class);
    // check if mapping was successful
    assertThat(alarmNotificationsDto).isNotNull();
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isNotNull();
    assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isEmpty();
}
Also used : AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) TreeSet(java.util.TreeSet) AlarmNotification(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto) Test(org.junit.jupiter.api.Test)

Example 3 with AlarmNotifications

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

the class SmartMeteringConfigurationEndpoint method setAlarmNotifications.

@PayloadRoot(localPart = "SetAlarmNotificationsRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetAlarmNotificationsAsyncResponse setAlarmNotifications(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetAlarmNotificationsRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
    final AlarmNotifications alarmNotifications = this.configurationMapper.map(request.getSetAlarmNotificationsRequestData().getAlarmNotifications(), AlarmNotifications.class);
    final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.SET_ALARM_NOTIFICATIONS).withMessageType(MessageType.SET_ALARM_NOTIFICATIONS).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
    final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, alarmNotifications);
    this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
    return this.configurationMapper.map(asyncResponse, SetAlarmNotificationsAsyncResponse.class);
}
Also used : AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) SetSpecialDaysAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysAsyncResponse) GetFirmwareVersionGasAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionGasAsyncResponse) GenerateAndReplaceKeysAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GenerateAndReplaceKeysAsyncResponse) ReplaceKeysAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ReplaceKeysAsyncResponse) SetPushSetupSmsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupSmsAsyncResponse) SetAdministrativeStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetAdministrativeStatusAsyncResponse) GetConfigurationObjectAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetConfigurationObjectAsyncResponse) SetEncryptionKeyExchangeOnGMeterAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetEncryptionKeyExchangeOnGMeterAsyncResponse) SetClockConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetClockConfigurationAsyncResponse) GetMbusEncryptionKeyStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetMbusEncryptionKeyStatusAsyncResponse) UpdateFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.UpdateFirmwareAsyncResponse) SetConfigurationObjectAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectAsyncResponse) SetPushSetupAlarmAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetPushSetupAlarmAsyncResponse) GetKeysAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysAsyncResponse) GetAdministrativeStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse) SetAlarmNotificationsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetAlarmNotificationsAsyncResponse) ConfigureDefinableLoadProfileAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigureDefinableLoadProfileAsyncResponse) GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionAsyncResponse) SetRandomisationSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetRandomisationSettingsAsyncResponse) SetActivityCalendarAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarAsyncResponse) SetMbusUserKeyByChannelAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetMbusUserKeyByChannelAsyncResponse) GetMbusEncryptionKeyStatusByChannelAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetMbusEncryptionKeyStatusByChannelAsyncResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 4 with AlarmNotifications

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

the class AlarmNotificationsConverter method convertTo.

@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications convertTo(final AlarmNotifications source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications result = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications();
    final List<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification> alarmNotifications = result.getAlarmNotification();
    final Set<AlarmNotification> sourceNotifications = source.getAlarmNotificationsSet();
    for (final AlarmNotification sourceNotification : sourceNotifications) {
        final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification alarmNotification = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification();
        alarmNotification.setAlarmType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AlarmType.valueOf(sourceNotification.getAlarmType().name()));
        alarmNotification.setEnabled(sourceNotification.isEnabled());
        alarmNotifications.add(alarmNotification);
    }
    return result;
}
Also used : AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) AlarmNotification(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification)

Example 5 with AlarmNotifications

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

Aggregations

AlarmNotifications (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications)6 AlarmNotification (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification)4 TreeSet (java.util.TreeSet)3 Test (org.junit.jupiter.api.Test)2 AlarmNotificationsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto)2 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse)1 ConfigureDefinableLoadProfileAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigureDefinableLoadProfileAsyncResponse)1 GenerateAndReplaceKeysAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GenerateAndReplaceKeysAsyncResponse)1 GetAdministrativeStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse)1 GetConfigurationObjectAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetConfigurationObjectAsyncResponse)1 GetFirmwareVersionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionAsyncResponse)1 GetFirmwareVersionGasAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionGasAsyncResponse)1 GetKeysAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysAsyncResponse)1 GetMbusEncryptionKeyStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetMbusEncryptionKeyStatusAsyncResponse)1 GetMbusEncryptionKeyStatusByChannelAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetMbusEncryptionKeyStatusByChannelAsyncResponse)1 ReplaceKeysAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ReplaceKeysAsyncResponse)1 SetActivityCalendarAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarAsyncResponse)1 SetAdministrativeStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetAdministrativeStatusAsyncResponse)1 SetAlarmNotificationsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetAlarmNotificationsAsyncResponse)1 SetClockConfigurationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetClockConfigurationAsyncResponse)1