use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithLists.
// To test Mapping if lists contain values
@Test
public void testPushSetupSmsMappingWithLists() {
// 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 PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
this.checkNonEmptyListMapping(pushSetupSms, pushSetupSmsDto);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithEmptyLists.
// To test if a PushSetupAlarm can be mapped if instance variables are
// initialized and lists are empty.
@Test
public void testPushSetupAlarmMappingWithEmptyLists() {
// build test data
final ArrayList<CosemObjectDefinition> pushObjectList = new ArrayList<>();
final ArrayList<WindowElement> communicationWindow = new ArrayList<>();
final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withEmptyLists(pushObjectList, communicationWindow).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);
assertThat(pushSetupAlarmDto.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNotNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement 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.WindowElement in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithEmptyLists.
// To test if a PushSetupAlarm can be mapped if instance variables are
// initialized and lists are empty.
@Test
public void testPushSetupSmsMappingWithEmptyLists() {
// build test data
final ArrayList<CosemObjectDefinition> pushObjectList = new ArrayList<>();
final ArrayList<WindowElement> communicationWindow = new ArrayList<>();
final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withEmptyLists(pushObjectList, communicationWindow).build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
assertThat(pushSetupSmsDto.getPushObjectList()).isNotNull();
assertThat(pushSetupSmsDto.getCommunicationWindow()).isNotNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method checkNonEmptyListMapping.
// method to test non-empty list mapping
private void checkNonEmptyListMapping(final PushSetupAlarm pushSetupAlarm, final PushSetupAlarmDto pushSetupAlarmDto) {
// test pushObjectList mapping
assertThat(pushSetupAlarm.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getPushObjectList().size()).isEqualTo(pushSetupAlarm.getPushObjectList().size());
final CosemObjectDefinition cosemObjectDefinition = pushSetupAlarm.getPushObjectList().get(0);
final CosemObjectDefinitionDto cosemObjectDefinitionDto = pushSetupAlarmDto.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(pushSetupAlarm.getCommunicationWindow()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow().size()).isEqualTo(pushSetupAlarm.getCommunicationWindow().size());
final WindowElement windowElement = pushSetupAlarm.getCommunicationWindow().get(0);
final WindowElementDto windowElementDto = pushSetupAlarmDto.getCommunicationWindow().get(0);
this.checkCosemDateTimeMapping(windowElement.getStartTime(), windowElementDto.getStartTime());
this.checkCosemDateTimeMapping(windowElement.getEndTime(), windowElementDto.getEndTime());
}
Aggregations