use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto 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));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetSendDestinationAndMethod.
@Test
void testSetSendDestinationAndMethod() 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);
final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withSendDestinationAndMethod(SEND_DESTINATION_AND_METHOD).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.verifySendDestinationAndMethodParameter(setParameters.get(0));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto 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);
}
Aggregations