Search in sources :

Example 6 with WindowElement

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

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

the class PushSetupSmsMappingTest method checkNonEmptyListMapping.

// method to test non-empty list mapping
private void checkNonEmptyListMapping(final PushSetupSms pushSetupSms, final PushSetupSmsDto pushSetupSmsDto) {
    // test pushObjectList mapping
    assertThat(pushSetupSms.getPushObjectList()).isNotNull();
    assertThat(pushSetupSmsDto.getPushObjectList()).isNotNull();
    assertThat(pushSetupSmsDto.getPushObjectList().size()).isEqualTo(pushSetupSms.getPushObjectList().size());
    final CosemObjectDefinition cosemObjectDefinition = pushSetupSms.getPushObjectList().get(0);
    final CosemObjectDefinitionDto cosemObjectDefinitionDto = pushSetupSmsDto.getPushObjectList().get(0);
    assertThat(cosemObjectDefinitionDto.getAttributeIndex()).isEqualTo(cosemObjectDefinition.getAttributeIndex());
    assertThat(cosemObjectDefinitionDto.getClassId()).isEqualTo(cosemObjectDefinition.getClassId());
    assertThat(cosemObjectDefinitionDto.getDataIndex()).isEqualTo(cosemObjectDefinition.getDataIndex());
    this.checkCosemObisCodeMapping(cosemObjectDefinition.getLogicalName(), cosemObjectDefinitionDto.getLogicalName());
    // test communicationWindow mapping
    assertThat(pushSetupSms.getCommunicationWindow()).isNotNull();
    assertThat(pushSetupSmsDto.getCommunicationWindow()).isNotNull();
    assertThat(pushSetupSmsDto.getCommunicationWindow().size()).isEqualTo(pushSetupSms.getCommunicationWindow().size());
    final WindowElement windowElement = pushSetupSms.getCommunicationWindow().get(0);
    final WindowElementDto windowElementDto = pushSetupSmsDto.getCommunicationWindow().get(0);
    this.checkCosemDateTimeMapping(windowElement.getStartTime(), windowElementDto.getStartTime());
    this.checkCosemDateTimeMapping(windowElement.getEndTime(), windowElementDto.getEndTime());
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) WindowElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)

Aggregations

CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)7 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)7 Test (org.junit.jupiter.api.Test)5 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)3 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)3 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)3 ArrayList (java.util.ArrayList)2 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)2 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)2 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)2 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)2 PushSetupSms (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms)2 CosemObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto)2 PushSetupSmsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)2 WindowElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto)2