Search in sources :

Example 1 with SpecialDaysRequest

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

the class SetSpecialDaysRequestMappingTest method testSetSpecialDaysRequestMappingFilledList.

/**
 * Tests mapping of a SetSpecialDaysRequest object, when its SpecialDaysRequestData object has a
 * filled List (1 entry).
 */
@Test
public void testSetSpecialDaysRequestMappingFilledList() {
    // build test data
    final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestData();
    final SpecialDay specialDay = new SpecialDay();
    specialDay.setDayId(DAY_ID);
    specialDay.setSpecialDayDate(COSEMDATE_BYTE_ARRAY);
    // To add a SpecialDay to the List, you need to use the getter in
    // combination with add()
    specialDaysRequestData.getSpecialDays().add(specialDay);
    final SetSpecialDaysRequest setSpecialDaysRequest = new SetSpecialDaysRequest();
    setSpecialDaysRequest.setDeviceIdentification(DEVICE_ID);
    setSpecialDaysRequest.setSpecialDaysRequestData(specialDaysRequestData);
    // actual mapping
    final SpecialDaysRequest specialDaysRequest = this.configurationMapper.map(setSpecialDaysRequest, SpecialDaysRequest.class);
    // check mapping
    assertThat(specialDaysRequest).isNotNull();
    assertThat(specialDaysRequest.getDeviceIdentification()).isNotNull();
    assertThat(specialDaysRequest.getSpecialDaysRequestData()).isNotNull();
    assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays()).isNotNull();
    assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0)).isNotNull();
    assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0).getSpecialDayDate()).isNotNull();
    assertThat(specialDaysRequest.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().size()).isEqualTo(specialDaysRequestData.getSpecialDays().size());
    assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0).getDayId()).isEqualTo(DAY_ID);
// For more info on the mapping of byte[] to CosemDate object, see the
// CosemDateConverterTest.
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) SpecialDay(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay) Test(org.junit.jupiter.api.Test)

Example 2 with SpecialDaysRequest

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

the class SetSpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNull.

/**
 * Tests mapping of a SetSpecialDaysRequest object, when its SetSpecialDaysRequest object is null.
 */
@Test
public void testSpecialDaysRequestMappingNull() {
    // build test data
    final SpecialDaysRequestData specialDaysRequestData = null;
    final SetSpecialDaysRequest setSpecialDaysRequest = new SetSpecialDaysRequest();
    setSpecialDaysRequest.setDeviceIdentification(DEVICE_ID);
    setSpecialDaysRequest.setSpecialDaysRequestData(specialDaysRequestData);
    // actual mapping
    final SpecialDaysRequest specialDaysRequest = this.configurationMapper.map(setSpecialDaysRequest, SpecialDaysRequest.class);
    // check mapping
    assertThat(specialDaysRequest.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(specialDaysRequest.getSpecialDaysRequestData()).isNull();
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) Test(org.junit.jupiter.api.Test)

Example 3 with SpecialDaysRequest

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

the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyListNoCosemDate.

// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value), where CosemDate is not specified.
@Test
public void testSpecialDaysRequestMappingNonEmptyListNoCosemDate() {
    final String deviceIdentification = "nr1";
    final int dayId = 1;
    final SpecialDay specialDay = new SpecialDay(new CosemDate(), dayId);
    final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
    final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
    final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
    assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
    assertThat(requestDataDto).isNotNull();
    assertThat(requestDataDto.getSpecialDays()).isNotNull();
    assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
    final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
    assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
    final CosemDate specialDayDate = specialDay.getSpecialDayDate();
    final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
    assertThat(specialDayDateDto.getYear()).isEqualTo(specialDayDate.getYear());
    assertThat(specialDayDateDto.getMonth()).isEqualTo(specialDayDate.getMonth());
    assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(specialDayDate.getDayOfMonth());
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SpecialDaysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto) SpecialDaysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequestData) SpecialDay(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDay) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) SpecialDayDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto) SpecialDaysRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto) Test(org.junit.jupiter.api.Test)

Example 4 with SpecialDaysRequest

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

the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyList.

// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value).
@Test
public void testSpecialDaysRequestMappingNonEmptyList() {
    final String deviceIdentification = "nr1";
    final int year = 2016;
    final int month = 3;
    final int dayOfMonth = 11;
    final int dayId = 1;
    final SpecialDay specialDay = new SpecialDay(new CosemDate(year, month, dayOfMonth), dayId);
    final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
    final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
    final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
    assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
    assertThat(requestDataDto).isNotNull();
    assertThat(requestDataDto.getSpecialDays()).isNotNull();
    assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
    final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
    assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
    final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
    assertThat(specialDayDateDto.getYear()).isEqualTo(year);
    assertThat(specialDayDateDto.getMonth()).isEqualTo(month);
    assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(dayOfMonth);
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SpecialDaysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto) SpecialDaysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequestData) SpecialDay(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDay) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) SpecialDayDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto) SpecialDaysRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto) Test(org.junit.jupiter.api.Test)

Example 5 with SpecialDaysRequest

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

the class SpecialDaysRequestMessageProcessor method handleMessage.

@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) throws FunctionalException {
    final SpecialDaysRequest specialDaysRequest = (SpecialDaysRequest) dataObject;
    this.configurationService.setSpecialDays(deviceMessageMetadata, specialDaysRequest);
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest)

Aggregations

SpecialDaysRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest)8 Test (org.junit.jupiter.api.Test)7 SpecialDaysRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequestData)4 SpecialDaysRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto)4 SetSpecialDaysRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest)3 SpecialDaysRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData)3 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)2 SpecialDay (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDay)2 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)2 SpecialDayDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto)2 SpecialDaysRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto)2 SpecialDay (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay)1