Search in sources :

Example 6 with CosemDateTime

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

the class PushSetupAlarmDtoConverterTest method convertTest.

@Test
void convertTest() {
    final List<WindowElement> testList = Collections.singletonList(new WindowElement(new CosemDateTime(), new CosemDateTime()));
    when(this.pushSetupAlarm.getCommunicationWindow()).thenReturn(testList);
    final CosemObisCode code = new CosemObisCode(1, 2, 3, 4, 5, 6);
    when(this.pushSetupAlarm.getPushObjectList()).thenReturn(Collections.singletonList(new CosemObjectDefinition(1, code, 2)));
    final PushSetupAlarmDto result = this.pushSetupAlarmDtoConverter.convert(this.pushSetupAlarm, null, this.mappingContext);
    assertThat(result.getCommunicationWindow()).isNotNull();
    assertThat(result.getPushObjectList()).isNotNull();
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 7 with CosemDateTime

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

the class ActivityCalendarBuilder method withFilledList.

public ActivityCalendarBuilder withFilledList() {
    final CosemDate date = new CosemDate(2016, 3, 16);
    final CosemTime time = new CosemTime(11, 45, 33);
    final int deviation = 1;
    final ClockStatus clockStatus = new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED);
    final CosemDateTime seasonStart = new CosemDateTime(date, time, deviation, clockStatus);
    final CosemTime startTime = time;
    final DayProfileAction dayProfileAction = new DayProfileAction(new Integer(10), startTime);
    final List<DayProfileAction> dayProfileActionList = new ArrayList<>();
    dayProfileActionList.add(dayProfileAction);
    final DayProfile dayProfile = new DayProfile(new Integer(10), dayProfileActionList);
    final WeekProfile weekProfile = WeekProfile.newBuilder().withWeekProfileName("weekProfile1").withMonday(dayProfile).withTuesday(dayProfile).withWednesday(dayProfile).withThursday(dayProfile).withFriday(dayProfile).withSaturday(dayProfile).withSunday(dayProfile).build();
    final SeasonProfile seasonProfile = new SeasonProfile("profile1", seasonStart, weekProfile);
    this.seasonProfileList.add(seasonProfile);
    return this;
}
Also used : WeekProfile(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WeekProfile) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) ArrayList(java.util.ArrayList) DayProfile(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfile) DayProfileAction(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfileAction) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) SeasonProfile(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile)

Example 8 with CosemDateTime

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

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

Example 10 with CosemDateTime

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

the class CosemDateTimeConverterTest method yearTest.

/**
 * Tests the mapping of the year property of a CosemDateTime object when it is unspecified.
 */
@Test
public void yearTest() {
    final CosemDateTime cosemDateTime = this.mapperFactory.getMapperFacade().map(COSEMDATETIME_BYTE_ARRAY_UNSPECIFIED_YEAR, CosemDateTime.class);
    assertThat(cosemDateTime).isNotNull();
    assertThat(cosemDateTime.getDate()).isNotNull();
    assertThat(cosemDateTime.getDate().getYear()).isNotNull();
    assertThat(cosemDateTime.getDate().getYear()).isEqualTo(CosemDate.YEAR_NOT_SPECIFIED);
}
Also used : CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) Test(org.junit.jupiter.api.Test)

Aggregations

CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)10 Test (org.junit.jupiter.api.Test)8 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)5 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)5 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)4 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)3 SeasonProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile)3 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)3 ArrayList (java.util.ArrayList)2 ActivityCalendar (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar)2 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)2 ByteBuffer (java.nio.ByteBuffer)1 DayProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfile)1 DayProfileAction (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfileAction)1 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)1 PushSetupSms (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms)1 WeekProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WeekProfile)1 PushSetupSmsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)1