Search in sources :

Example 6 with GetResultImpl

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

the class SetPushSetupAlarmCommandExecutorTest method testSetPushObjectListWithInvalidPushObject.

@Test
void testSetPushObjectListWithInvalidPushObject() throws IOException {
    // SETUP
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.OBJECT_UNDEFINED));
    final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withPushObjectList(PUSH_OBJECT_LIST).build();
    // CALL
    final Throwable thrown = catchThrowable(() -> {
        this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
    });
    // VERIFY
    assertThat(thrown).isInstanceOf(ProtocolAdapterException.class);
}
Also used : GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) AttributeAddress(org.openmuc.jdlms.AttributeAddress) AssertionsForClassTypes.catchThrowable(org.assertj.core.api.AssertionsForClassTypes.catchThrowable) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 7 with GetResultImpl

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

the class JdlmsObjectToStringUtilTest method testDescribeGetResultWithNullResultCodeAndData.

@Test
public void testDescribeGetResultWithNullResultCodeAndData() {
    final GetResult getResult = new GetResultImpl(null, null);
    final String description = JdlmsObjectToStringUtil.describeGetResult(getResult);
    assertThat(description).isEqualTo("Result code is null, Result data is null");
}
Also used : GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) Test(org.junit.jupiter.api.Test)

Example 8 with GetResultImpl

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

the class GetPowerQualityProfileNoSelectiveAccessHandlerTest method createPartialNotAllowedCaptureObjects.

private List<GetResult> createPartialNotAllowedCaptureObjects() {
    final DataObject allowedCaptureObject1 = DataObject.newStructureData(DataObject.newUInteger32Data(8), DataObject.newOctetStringData(new byte[] { 0, 0, 1, 0, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject nonAllowedCaptureObject2 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 80, 0, 32, 32, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final DataObject allowedCaptureObject3 = DataObject.newStructureData(DataObject.newUInteger32Data(1), DataObject.newOctetStringData(new byte[] { 1, 0, 52, 32, 0, (byte) 255 }), DataObject.newInteger32Data(2), DataObject.newUInteger32Data(0));
    final GetResult getResult = new GetResultImpl(DataObject.newArrayData(Arrays.asList(allowedCaptureObject1, nonAllowedCaptureObject2, allowedCaptureObject3)));
    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 9 with GetResultImpl

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

the class GetPowerQualityProfileNoSelectiveAccessHandlerTest method createProfileEntries.

private List<GetResult> createProfileEntries() {
    final List<DataObject> structures = new ArrayList<>();
    final DataObject structureData1 = DataObject.newStructureData(DataObject.newOctetStringData(new byte[] { 7, (byte) 228, 3, 15, 7, 0, 0, 0, 0, (byte) 255, (byte) 196, 0 }), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2));
    structures.add(structureData1);
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    final GetResult getResult = new GetResultImpl(DataObject.newArrayData(structures));
    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) ArrayList(java.util.ArrayList)

Example 10 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 createProfileEntries.

private List<GetResult> createProfileEntries() {
    final List<DataObject> structures = new ArrayList<>();
    final DataObject structureData1 = DataObject.newStructureData(DataObject.newOctetStringData(new byte[] { 7, (byte) 228, 3, 15, 7, 0, 0, 0, 0, (byte) 255, (byte) 196, 0 }), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2));
    structures.add(structureData1);
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    structures.add(DataObject.newStructureData(DataObject.newNullData(), DataObject.newUInteger32Data(3), DataObject.newUInteger32Data(2)));
    final GetResult getResult = new GetResultImpl(DataObject.newArrayData(structures));
    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) ArrayList(java.util.ArrayList)

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