Search in sources :

Example 1 with MethodAccessItemDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto 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());
}
Also used : AccessRightDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto) AttributeAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto) AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) ArrayList(java.util.ArrayList) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto) AccessSelectorListDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto) AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) AttributeAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto) MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto) AttributeAccessModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto) Test(org.junit.jupiter.api.Test)

Example 2 with MethodAccessItemDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method convertMethodAccessDescriptor.

private MethodAccessDescriptorDto convertMethodAccessDescriptor(final List<DataObject> methodAccessDescriptor) throws ProtocolAdapterException {
    final List<MethodAccessItemDto> methodAccessItems = new ArrayList<>();
    for (final DataObject methodAccessItemRaw : methodAccessDescriptor) {
        final List<DataObject> methodAccessItem = methodAccessItemRaw.getValue();
        methodAccessItems.add(new MethodAccessItemDto(this.dlmsHelper.readLong(methodAccessItem.get(ACCESS_RIGHTS_METHOD_ACCESS_METHOD_ID_INDEX), "").intValue(), MethodAccessModeTypeDto.values()[this.dlmsHelper.readLong(methodAccessItem.get(ACCESS_RIGHTS_METHOD_ACCESS_ACCESS_MODE_INDEX), "").intValue()]));
    }
    return new MethodAccessDescriptorDto(methodAccessItems);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) ArrayList(java.util.ArrayList) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)

Example 3 with MethodAccessItemDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto in project open-smart-grid-platform by OSGP.

the class AssociationLnListTypeMappingTest method checkMethodAccessItem.

private void checkMethodAccessItem(final List<MethodAccessItem> methodAccessItemList, final List<MethodAccessItemDto> methodAccessItemDtoList) {
    assertThat(methodAccessItemDtoList.size()).isEqualTo(methodAccessItemList.size());
    final Iterator<MethodAccessItem> methodAccessItemIterator = methodAccessItemList.iterator();
    final Iterator<MethodAccessItemDto> methodAccessItemDtoIterator = methodAccessItemDtoList.iterator();
    while (methodAccessItemIterator.hasNext() && methodAccessItemDtoIterator.hasNext()) {
        final MethodAccessItem methodAccessItem = methodAccessItemIterator.next();
        final MethodAccessItemDto methodAccessItemDto = methodAccessItemDtoIterator.next();
        assertThat(methodAccessItemDto.getAccessMode().name()).isEqualTo(methodAccessItem.getAccessMode().name());
        assertThat(methodAccessItemDto.getMethodId()).isEqualTo(methodAccessItem.getMethodId());
    }
}
Also used : MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) MethodAccessItem(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessItem)

Aggregations

MethodAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto)3 ArrayList (java.util.ArrayList)2 MethodAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)2 Test (org.junit.jupiter.api.Test)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 AssociationLnListType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType)1 MethodAccessItem (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessItem)1 AccessRightDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto)1 AccessSelectorListDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto)1 AssociationLnListElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto)1 AssociationLnListTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto)1 AttributeAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto)1 AttributeAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto)1 AttributeAccessModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1