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();
}
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;
}
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);
}
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);
}
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);
}
Aggregations