use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto 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.AccessRightDto in project open-smart-grid-platform by OSGP.
the class GetAssociationLnObjectsCommandExecutor method convertAccessRights.
private AccessRightDto convertAccessRights(final DataObject dataObject) throws ProtocolAdapterException {
if (!dataObject.isComplex()) {
return null;
}
final List<DataObject> accessRights = dataObject.getValue();
final List<DataObject> attributeAccessDescriptorObjects = accessRights.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_INDEX).getValue();
final AttributeAccessDescriptorDto attributeAccessDescriptor = this.convertAttributeAccessDescriptor(attributeAccessDescriptorObjects);
final List<DataObject> methodAccessDescriptorObjects = accessRights.get(ACCESS_RIGHTS_METHOD_ACCESS_INDEX).getValue();
final MethodAccessDescriptorDto methodAccessDescriptor = this.convertMethodAccessDescriptor(methodAccessDescriptorObjects);
return new AccessRightDto(attributeAccessDescriptor, methodAccessDescriptor);
}
Aggregations