use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto in project open-smart-grid-platform by OSGP.
the class AssociationLnListTypeMappingTest method testAssociationLnListTypeDtoMappingWithNonEmptyLists.
@Test
public void testAssociationLnListTypeDtoMappingWithNonEmptyLists() {
// build test data
final List<AttributeAccessItemDto> listAttributeAccessItemDto = new ArrayList<>();
final AttributeAccessModeTypeDto accessMode = AttributeAccessModeTypeDto.NO_ACCESS;
final List<Integer> listInteger = new ArrayList<>();
final AccessSelectorListDto accessSelectors = new AccessSelectorListDto(listInteger);
listAttributeAccessItemDto.add(new AttributeAccessItemDto(1, accessMode, accessSelectors));
final AttributeAccessDescriptorDto attributeAccessDescriptorDto = new AttributeAccessDescriptorDto(listAttributeAccessItemDto);
final List<MethodAccessItemDto> listMethodAccessItemDto = new ArrayList<>();
final MethodAccessDescriptorDto methodAccessDescriptorDto = new MethodAccessDescriptorDto(listMethodAccessItemDto);
final AssociationLnListElementDto associationLnElementDto = new AssociationLnListElementDto(72, 2, new CosemObisCodeDto(new int[] { 1, 1, 1, 1, 1, 1 }), new AccessRightDto(attributeAccessDescriptorDto, methodAccessDescriptorDto));
final AssociationLnListTypeDto associationLnListTypeDto = new AssociationLnListTypeDtoBuilder().withNonEmptyLists(associationLnElementDto).build();
// actual mapping
final AssociationLnListType associationLnListType = this.configurationMapper.map(associationLnListTypeDto, AssociationLnListType.class);
// check values
assertThat(associationLnListType).isNotNull();
this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto in project open-smart-grid-platform by OSGP.
the class AssociationLnListTypeMappingTest method testAssociationLnListTypeDtoMappingWithEmptyLists.
@Test
public void testAssociationLnListTypeDtoMappingWithEmptyLists() {
// build test data
final AssociationLnListTypeDto associationLnListTypeDto = new AssociationLnListTypeDtoBuilder().withEmptyLists().build();
// actual mapping
final AssociationLnListType associationLnListType = this.configurationMapper.map(associationLnListTypeDto, AssociationLnListType.class);
// check values
assertThat(associationLnListType).isNotNull();
this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto in project open-smart-grid-platform by OSGP.
the class AssociationLnListTypeMappingTest method testAssociationLnListTypeMappingWithEmptyLists.
@Test
public void testAssociationLnListTypeMappingWithEmptyLists() {
// build test data
final AssociationLnListType associationLnListType = new AssociationLnListTypeBuilder().withEmptyLists().build();
// actual mapping
final AssociationLnListTypeDto associationLnListTypeDto = this.configurationMapper.map(associationLnListType, AssociationLnListTypeDto.class);
// check values
assertThat(associationLnListTypeDto).isNotNull();
this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto in project open-smart-grid-platform by OSGP.
the class GetAssociationLnObjectsCommandExecutor method execute.
@Override
public AssociationLnListTypeDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void object, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
conn.getDlmsMessageListener().setDescription("GetAssociationLnObjects, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
LOGGER.debug("Retrieving Association LN objects for class id: {}, obis code: {}, attribute id: {}", CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final List<GetResult> getResultList = this.dlmsHelper.getAndCheck(conn, device, "Association LN Objects", attributeAddress);
final DataObject resultData = getResultList.get(0).getResultData();
if (!resultData.isComplex()) {
throw new ProtocolAdapterException("Unexpected type of element");
}
final List<DataObject> associationLnListObjects = resultData.getValue();
final List<AssociationLnListElementDto> elements = this.convertAssociationLnList(associationLnListObjects);
return new AssociationLnListTypeDto(elements);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto 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());
}
Aggregations