Search in sources :

Example 1 with ActivityCalendar

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

the class ActivityCalendarMappingTest method testNullCosemDateTime.

// Neither the CosemDateTime or List<SeasonProfile> of a ActivityCalendar
// may ever be null. Tests to make sure a NullPointerException is thrown
// when one is.
@Test
public void testNullCosemDateTime() {
    final String calendarName = "calendar";
    final CosemDateTime activePassiveCalendarTime = null;
    final List<SeasonProfile> seasonProfileList = new ArrayList<>();
    assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
        new ActivityCalendar(calendarName, activePassiveCalendarTime, seasonProfileList);
    });
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) ArrayList(java.util.ArrayList) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) SeasonProfile(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile) Test(org.junit.jupiter.api.Test)

Example 2 with ActivityCalendar

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

the class ActivityCalendarMappingTest method testWithCosemDateTimeAndEmptyList.

// Test mapping with a CosemDateTime object AND an empty list
@Test
public void testWithCosemDateTimeAndEmptyList() {
    // build test data
    final ActivityCalendar activityCalendar = new ActivityCalendarBuilder().withCosemDateTime(this.cosemDateTime).build();
    // actual mapping
    final ActivityCalendarDto activityCalendarDto = this.configurationMapper.map(activityCalendar, ActivityCalendarDto.class);
    // check if mapping succeeded
    assertThat(activityCalendarDto).isNotNull();
    assertThat(activityCalendarDto.getActivatePassiveCalendarTime()).isNotNull();
    assertThat(activityCalendarDto.getSeasonProfileList()).isNotNull();
    assertThat(activityCalendarDto.getCalendarName()).isEqualTo(activityCalendar.getCalendarName());
    this.checkEmptyListMapping(activityCalendar.getSeasonProfileList(), activityCalendarDto.getSeasonProfileList());
    this.checkCosemDateTimeMapping(activityCalendar.getActivatePassiveCalendarTime(), activityCalendarDto.getActivatePassiveCalendarTime());
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) ActivityCalendarDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto) Test(org.junit.jupiter.api.Test)

Example 3 with ActivityCalendar

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

the class ActivityCalendarMappingTest method testNullList.

// Neither the CosemDateTime or List<SeasonProfile> of a ActivityCalendar
// may ever be null. Tests to make sure a NullPointerException is thrown
// when one is.
@Test
public void testNullList() {
    final String calendarName = "calendar";
    final CosemDateTime activePassiveCalendarTime = new CosemDateTime();
    final List<SeasonProfile> seasonProfileList = null;
    assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
        new ActivityCalendar(calendarName, activePassiveCalendarTime, seasonProfileList);
    });
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) SeasonProfile(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile) Test(org.junit.jupiter.api.Test)

Example 4 with ActivityCalendar

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

the class SmartMeteringConfigurationEndpoint method setActivityCalendar.

@PayloadRoot(localPart = "SetActivityCalendarRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetActivityCalendarAsyncResponse setActivityCalendar(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetActivityCalendarRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
    final ActivityCalendar activityCalendar = this.configurationMapper.map(request.getActivityCalendarData().getActivityCalendar(), ActivityCalendar.class);
    final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.SET_ACTIVITY_CALENDAR).withMessageType(MessageType.SET_ACTIVITY_CALENDAR).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
    final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, activityCalendar);
    this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
    return this.configurationMapper.map(asyncResponse, SetActivityCalendarAsyncResponse.class);
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) 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 5 with ActivityCalendar

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

the class ActivityCalendarTypeMappingTest method testActivityCalendarTypeMapping.

/**
 * Method to test mapping from ActivityCalendarType to ActivityCalendar.
 */
@Test
public void testActivityCalendarTypeMapping() {
    // build test data
    final ActivityCalendarType activityCalendarType = this.buildActivityCalendarTypeObject();
    // actual mapping
    final ActivityCalendar activityCalendar = this.configurationMapper.map(activityCalendarType, ActivityCalendar.class);
    // check mapping
    assertThat(activityCalendar).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList()).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList().get(0)).isNotNull();
    // For more info on byte[] to CosemDateTime object mapping, refer to the
    // CosemDateTimeConverterTest.
    assertThat(activityCalendar.getActivatePassiveCalendarTime()).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonStart()).isNotNull();
    assertThat(activityCalendar.getCalendarName()).isEqualTo(CALENDARNAME);
    assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonProfileName()).isEqualTo(SEASONPROFILENAME);
    this.checkWeekProfileMapping(activityCalendar.getSeasonProfileList().get(0).getWeekProfile());
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType) Test(org.junit.jupiter.api.Test)

Aggregations

ActivityCalendar (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar)7 Test (org.junit.jupiter.api.Test)5 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)2 SeasonProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile)2 ActivityCalendarDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto)2 ArrayList (java.util.ArrayList)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse)1 ActivityCalendarType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType)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