Search in sources :

Example 11 with CosemDate

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

the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithLists.

// To test Mapping if lists contain values
@Test
public void testPushSetupAlarmMappingWithLists() {
    // build test data
    final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
    final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
    final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final WindowElement windowElement = new WindowElement(startTime, endTime);
    final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
    // actual mapping
    final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
    // check values
    this.checkCosemObisCodeMapping(pushSetupAlarm.getLogicalName(), pushSetupAlarmDto.getLogicalName());
    this.checkSendDestinationAndMethodMapping(pushSetupAlarm, pushSetupAlarmDto);
    this.checkIntegerMapping(pushSetupAlarm, pushSetupAlarmDto);
    this.checkNonEmptyListMapping(pushSetupAlarm, pushSetupAlarmDto);
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Example 12 with CosemDate

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

the class PushSetupAlarmMappingTest method checkCosemDateTimeMapping.

// method to test mapping of CosemDateTime objects
private void checkCosemDateTimeMapping(final CosemDateTime cosemDateTime, final CosemDateTimeDto cosemDateTimeDto) {
    // make sure neither is null
    assertThat(cosemDateTime).isNotNull();
    assertThat(cosemDateTimeDto).isNotNull();
    // check variables
    assertThat(cosemDateTimeDto.getDeviation()).isEqualTo(cosemDateTime.getDeviation());
    final ClockStatus clockStatus = cosemDateTime.getClockStatus();
    final ClockStatusDto clockStatusDto = cosemDateTimeDto.getClockStatus();
    assertThat(clockStatusDto.getStatus()).isEqualTo(clockStatus.getStatus());
    assertThat(clockStatusDto.isSpecified()).isEqualTo(clockStatus.isSpecified());
    final CosemDate cosemDate = cosemDateTime.getDate();
    final CosemDateDto cosemDateDto = cosemDateTimeDto.getDate();
    assertThat(cosemDateDto).isEqualToComparingFieldByField(cosemDate);
    final CosemTime cosemTime = cosemDateTime.getTime();
    final CosemTimeDto cosemTimeDto = cosemDateTimeDto.getTime();
    assertThat(cosemTimeDto).isEqualToComparingFieldByField(cosemTime);
}
Also used : ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) ClockStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)

Example 13 with CosemDate

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

the class CosemDateTimeConverterTest method testToCosemDateTimeMapping.

/**
 * Tests if mapping a byte[] to a CosemDateTime object succeeds.
 */
@Test
public void testToCosemDateTimeMapping() {
    // actual mapping
    final CosemDateTime cosemDateTime = this.mapperFactory.getMapperFacade().map(COSEMDATETIME_BYTE_ARRAY_NORMAL, CosemDateTime.class);
    // check mapping
    assertThat(cosemDateTime).isNotNull();
    final CosemDate cosemDate = cosemDateTime.getDate();
    assertThat(((byte) (cosemDate.getYear() >> 8))).isEqualTo(FIRST_BYTE_FOR_YEAR);
    assertThat(((byte) (cosemDate.getYear() & 0xFF))).isEqualTo(SECOND_BYTE_FOR_YEAR);
    assertThat(cosemDate.getMonth()).isEqualTo(BYTE_FOR_MONTH);
    assertThat(cosemDate.getDayOfMonth()).isEqualTo(BYTE_FOR_DAY_OF_MONTH);
    assertThat((byte) cosemDate.getDayOfWeek()).isEqualTo(BYTE_FOR_DAY_OF_WEEK);
    final CosemTime cosemTime = cosemDateTime.getTime();
    assertThat(cosemTime.getHour()).isEqualTo(BYTE_FOR_HOUR_OF_DAY);
    assertThat(cosemTime.getMinute()).isEqualTo(BYTE_FOR_MINUTE_OF_HOUR);
    assertThat(cosemTime.getSecond()).isEqualTo(BYTE_FOR_SECOND_OF_MINUTE);
    assertThat(cosemTime.getHundredths()).isEqualTo(BYTE_FOR_HUNDREDS_0F_SECONDS);
    final int deviation = cosemDateTime.getDeviation();
    assertThat(((byte) (deviation >> 8))).isEqualTo(FIRST_BYTE_FOR_DEVIATION);
    assertThat(((byte) (deviation & 0xFF))).isEqualTo(SECOND_BYTE_FOR_DEVIATION);
    assertThat(((byte) ClockStatus.STATUS_NOT_SPECIFIED)).isEqualTo(BYTE_FOR_CLOCKSTATUS);
}
Also used : CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Aggregations

CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)13 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)8 Test (org.junit.jupiter.api.Test)7 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)7 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)5 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)5 ClockStatusDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto)3 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)3 ByteBuffer (java.nio.ByteBuffer)2 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)2 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)2 SpecialDay (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDay)2 SpecialDaysRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest)2 SpecialDaysRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequestData)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 SpecialDayDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto)2 SpecialDaysRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto)2 SpecialDaysRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto)2 ArrayList (java.util.ArrayList)1 DayProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfile)1