Search in sources :

Example 1 with AssociationLnListTypeDto

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());
}
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 AssociationLnListTypeDto

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());
}
Also used : AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) Test(org.junit.jupiter.api.Test)

Example 3 with AssociationLnListTypeDto

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());
}
Also used : AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) Test(org.junit.jupiter.api.Test)

Example 4 with AssociationLnListTypeDto

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);
}
Also used : AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 5 with AssociationLnListTypeDto

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());
}
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

AssociationLnListTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto)5 Test (org.junit.jupiter.api.Test)4 AssociationLnListType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType)4 ArrayList (java.util.ArrayList)2 AssociationLnListElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 GetResult (org.openmuc.jdlms.GetResult)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)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 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 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)1 MethodAccessDescriptor (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MethodAccessDescriptor)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