use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelperTest method testGetChannelElementValuesInvalidManufacturerId.
@Test
void testGetChannelElementValuesInvalidManufacturerId() throws Exception {
final GetResult manufacturerIdentificationInvalid = new GetResultImpl(DataObject.newUInteger16Data(123));
final List<GetResult> resultList = new ArrayList<>(Arrays.asList(this.primaryAddress, this.identificationNumberInBcd, manufacturerIdentificationInvalid, 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);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
this.deviceChannelsHelper.getChannelElementValues(this.conn, this.device, (short) 1);
});
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetPushObjectList.
@Test
void testSetPushObjectList() throws ProtocolAdapterException, IOException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.SUCCESS));
final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
pushSetupAlarmBuilder.withPushObjectList(PUSH_OBJECT_LIST);
final PushSetupAlarmDto pushSetupAlarmDto = pushSetupAlarmBuilder.build();
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(1)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifyPushObjectListParameter(setParameters.get(0));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.
the class JdlmsObjectToStringUtilTest method testDescribeGetResults.
@Test
public void testDescribeGetResults() {
final GetResult getResult1 = new GetResultImpl(DataObject.newInteger32Data(100), AccessResultCode.SUCCESS);
final GetResult getResult2 = new GetResultImpl(DataObject.newVisibleStringData("Test".getBytes()), AccessResultCode.OBJECT_UNDEFINED);
final String description = JdlmsObjectToStringUtil.describeGetResults(Arrays.asList(getResult1, getResult2));
assertThat(description).isEqualTo("{SUCCESS, DOUBLE_LONG Value: 100 - OBJECT_UNDEFINED, VISIBLE_STRING Value: Test}");
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.
the class JdlmsObjectToStringUtilTest method testDescribeGetResultWithSuccess.
@Test
public void testDescribeGetResultWithSuccess() {
final GetResult getResult = new GetResultImpl(DataObject.newInteger32Data(100), AccessResultCode.SUCCESS);
final String description = JdlmsObjectToStringUtil.describeGetResult(getResult);
assertThat(description).isEqualTo("SUCCESS, DOUBLE_LONG Value: 100");
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetBothSendDestinationAndPushObjectList.
@Test
void testSetBothSendDestinationAndPushObjectList() throws ProtocolAdapterException, IOException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.SUCCESS));
final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withSendDestinationAndMethod(SEND_DESTINATION_AND_METHOD).withPushObjectList(PUSH_OBJECT_LIST).build();
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(2)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySendDestinationAndMethodParameter(setParameters.get(0));
this.verifyPushObjectListParameter(setParameters.get(1));
}
Aggregations