Search in sources :

Example 1 with CosemObisCode

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode 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);
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Example 2 with CosemObisCode

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

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

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

the class AssociationLnListTypeMappingTest method testAssociationLnListTypeMappingWithNonEmptyLists.

@Test
public void testAssociationLnListTypeMappingWithNonEmptyLists() {
    // build test data
    final List<AttributeAccessItem> listAttributeAccessItem = new ArrayList<>();
    final AttributeAccessModeType accessMode = AttributeAccessModeType.NO_ACCESS;
    final List<Integer> listInteger = new ArrayList<>();
    final AccessSelectorList accessSelectors = new AccessSelectorList(listInteger);
    listAttributeAccessItem.add(new AttributeAccessItem(1, accessMode, accessSelectors));
    final AttributeAccessDescriptor attributeAccessDescriptor = new AttributeAccessDescriptor(listAttributeAccessItem);
    final List<MethodAccessItem> listMethodAccessItem = new ArrayList<>();
    final MethodAccessDescriptor methodAccessDescriptor = new MethodAccessDescriptor(listMethodAccessItem);
    final AssociationLnListElement associationLnElement = new AssociationLnListElement(72, 2, new CosemObisCode(new int[] { 1, 1, 1, 1, 1, 1 }), new AccessRight(attributeAccessDescriptor, methodAccessDescriptor));
    final AssociationLnListType associationLnListType = new AssociationLnListTypeBuilder().withNonEmptyLists(associationLnElement).build();
    // actual mapping
    final AssociationLnListTypeDto associationLnListTypeDto = this.configurationMapper.map(associationLnListType, AssociationLnListTypeDto.class);
    // check values
    assertThat(associationLnListTypeDto).isNotNull();
    this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
Also used : MethodAccessDescriptor(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessDescriptor) ArrayList(java.util.ArrayList) AttributeAccessDescriptor(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessDescriptor) AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) AttributeAccessItem(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessItem) AssociationLnListElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListElement) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) MethodAccessItem(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessItem) AttributeAccessModeType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessModeType) AccessRight(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AccessRight) AccessSelectorList(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AccessSelectorList) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)4 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)3 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)3 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 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)2 ArrayList (java.util.ArrayList)1 AccessRight (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AccessRight)1 AccessSelectorList (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AccessSelectorList)1 AssociationLnListElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListElement)1 AssociationLnListType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType)1 AttributeAccessDescriptor (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessDescriptor)1 AttributeAccessItem (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessItem)1 AttributeAccessModeType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AttributeAccessModeType)1 MethodAccessDescriptor (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessDescriptor)1 MethodAccessItem (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessItem)1 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)1