use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto 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.AttributeAccessItemDto in project open-smart-grid-platform by OSGP.
the class GetAssociationLnObjectsCommandExecutor method convertAttributeAccessDescriptor.
private AttributeAccessDescriptorDto convertAttributeAccessDescriptor(final List<DataObject> attributeAccessDescriptor) throws ProtocolAdapterException {
final List<AttributeAccessItemDto> attributeAccessItems = new ArrayList<>();
for (final DataObject attributeAccessItemRaw : attributeAccessDescriptor) {
final List<DataObject> attributeAccessItem = attributeAccessItemRaw.getValue();
final AccessSelectorListDto asl;
if (attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_SELECTORS_INDEX).isNull()) {
asl = new AccessSelectorListDto(Collections.emptyList());
} else {
final List<DataObject> accessSelectorsObjects = attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_SELECTORS_INDEX).getValue();
asl = new AccessSelectorListDto(this.convertAccessSelectors(accessSelectorsObjects));
}
attributeAccessItems.add(new AttributeAccessItemDto(this.dlmsHelper.readLong(attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ATTRIBUTE_ID_INDEX), "").intValue(), AttributeAccessModeTypeDto.values()[this.dlmsHelper.readLong(attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_MODE_INDEX), "").intValue()], asl));
}
return new AttributeAccessDescriptorDto(attributeAccessItems);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto in project open-smart-grid-platform by OSGP.
the class AssociationLnListTypeMappingTest method checkAttributeAccessItem.
private void checkAttributeAccessItem(final List<AttributeAccessItem> attributeAccessItemList, final List<AttributeAccessItemDto> attributeAccessItemDtoList) {
assertThat(attributeAccessItemDtoList.size()).isEqualTo(attributeAccessItemList.size());
final Iterator<AttributeAccessItem> attributeAccessItemIterator = attributeAccessItemList.iterator();
final Iterator<AttributeAccessItemDto> attributeAccessItemDtoIterator = attributeAccessItemDtoList.iterator();
while (attributeAccessItemIterator.hasNext() && attributeAccessItemDtoIterator.hasNext()) {
final AttributeAccessItem attributeAccessItem = attributeAccessItemIterator.next();
final AttributeAccessItemDto attributeAccessItemDto = attributeAccessItemDtoIterator.next();
assertThat(attributeAccessItemDto.getAccessMode().name()).isEqualTo(attributeAccessItem.getAccessMode().name());
assertThat(attributeAccessItemDto.getAccessSelectors().getAccessSelector()).isEqualTo(attributeAccessItem.getAccessSelectors().getAccessSelector());
assertThat(attributeAccessItemDto.getAttributeId()).isEqualTo(attributeAccessItem.getAttributeId());
}
}
Aggregations