Search in sources :

Example 11 with GetResultImpl

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileSelectiveAccessHandlerTest method createCaptureObjectsProfile2.

private List<GetResult> createCaptureObjectsProfile2() {
    final DataObject structureData1 = DataObject.newStructureData(DataObject.newUInteger32Data(8), DataObject.newOctetStringData(new byte[] { 0, 0, 1, 0, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject structureData2 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 1, 0, 31, 24, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject structureData3 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 1, 0, 51, 24, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final GetResult getResult = new GetResultImpl(DataObject.newArrayData(Arrays.asList(structureData1, structureData2, structureData3)));
    return Collections.singletonList(getResult);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)

Example 12 with GetResultImpl

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileSelectiveAccessHandlerTest method createCaptureObjects.

private List<GetResult> createCaptureObjects() {
    final DataObject structureData1 = DataObject.newStructureData(DataObject.newUInteger32Data(8), DataObject.newOctetStringData(new byte[] { 0, 0, 1, 0, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject structureData2 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 1, 0, 21, 4, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject structureData3 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 1, 0, 23, 4, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final GetResult getResult = new GetResultImpl(DataObject.newArrayData(Arrays.asList(structureData1, structureData2, structureData3)));
    return Collections.singletonList(getResult);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)

Example 13 with GetResultImpl

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.

the class DeviceChannelsHelperTest method testGetChannelElementValuesIdenfiticationNumberNull.

@Test
public void testGetChannelElementValuesIdenfiticationNumberNull() throws Exception {
    final GetResult identificationNumberNull = new GetResultImpl(null);
    final List<GetResult> resultList = new ArrayList<>(Arrays.asList(this.primaryAddress, identificationNumberNull, this.manufacturerIdentification, this.version, this.deviceType));
    when(this.device.isWithListSupported()).thenReturn(true);
    when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.get(anyList())).thenReturn(resultList);
    final ChannelElementValuesDto values = this.deviceChannelsHelper.getChannelElementValues(this.conn, this.device, (short) 1);
    assertThat(values.getIdentificationNumber()).isNull();
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 14 with GetResultImpl

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.

the class GetActualPowerQualityCommandExecutorTest method generateMockedResult.

private List<GetResult> generateMockedResult(final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas, final AccessResultCode resultCode, final DataObject dateTimeDataObject) {
    final List<GetResult> results = new ArrayList<>();
    int idx = 1;
    for (final PowerQualityObjectMetadata metadata : metadatas) {
        if (metadata.getClassId() == CLASS_ID_CLOCK) {
            results.add(new GetResultImpl(dateTimeDataObject, resultCode));
        } else {
            results.add(new GetResultImpl(DataObject.newInteger64Data(idx++), resultCode));
            if (metadata.getClassId() == CLASS_ID_REGISTER) {
                final List<DataObject> scalerUnit = new ArrayList<>();
                scalerUnit.add(DataObject.newInteger64Data(1));
                scalerUnit.add(DataObject.newInteger64Data(DlmsUnitTypeDto.VOLT.getIndex()));
                results.add(new GetResultImpl(DataObject.newArrayData(scalerUnit), resultCode));
            }
        }
    }
    return results;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) ArrayList(java.util.ArrayList) PowerQualityObjectMetadata(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)

Aggregations

GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)14 GetResult (org.openmuc.jdlms.GetResult)11 Test (org.junit.jupiter.api.Test)8 DataObject (org.openmuc.jdlms.datatypes.DataObject)6 ArrayList (java.util.ArrayList)5 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)3 AccessResultCode (org.openmuc.jdlms.AccessResultCode)2 SetParameter (org.openmuc.jdlms.SetParameter)2 AssertionsForClassTypes.catchThrowable (org.assertj.core.api.AssertionsForClassTypes.catchThrowable)1 PowerQualityObjectMetadata (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)1 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)1