Search in sources :

Example 11 with PushSetupAlarmDto

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));
}
Also used : GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) AttributeAddress(org.openmuc.jdlms.AttributeAddress) AccessResultCode(org.openmuc.jdlms.AccessResultCode) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) SetParameter(org.openmuc.jdlms.SetParameter) Test(org.junit.jupiter.api.Test)

Example 12 with PushSetupAlarmDto

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));
}
Also used : AccessResultCode(org.openmuc.jdlms.AccessResultCode) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) SetParameter(org.openmuc.jdlms.SetParameter) Test(org.junit.jupiter.api.Test)

Example 13 with PushSetupAlarmDto

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

Aggregations

PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)13 Test (org.junit.jupiter.api.Test)10 AccessResultCode (org.openmuc.jdlms.AccessResultCode)3 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 SetParameter (org.openmuc.jdlms.SetParameter)3 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)3 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)3 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)3 ArrayList (java.util.ArrayList)2 AssertionsForClassTypes.catchThrowable (org.assertj.core.api.AssertionsForClassTypes.catchThrowable)2 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)2 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)2 GetResult (org.openmuc.jdlms.GetResult)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)1 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)1 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1