Search in sources :

Example 6 with ActionResponseDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto in project open-smart-grid-platform by OSGP.

the class ActionMapperResponseService method mapAllActions.

public BundleMessagesResponse mapAllActions(final BundleMessagesRequestDto bundleMessageResponseDto) throws FunctionalException {
    final List<ActionResponse> actionResponseList = new ArrayList<>();
    for (final ActionResponseDto action : bundleMessageResponseDto.getAllResponses()) {
        final ConfigurableMapper mapper = this.getMapper(action);
        final Class<? extends ActionResponse> clazz = this.getClazz(action);
        // mapper is monitoring mapper
        final ActionResponse actionValueResponseObject = this.doMap(action, mapper, clazz);
        actionResponseList.add(actionValueResponseObject);
    }
    return new BundleMessagesResponse(actionResponseList);
}
Also used : ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) ArrayList(java.util.ArrayList) BundleMessagesResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessagesResponse) ConfigurableMapper(ma.glasnost.orika.impl.ConfigurableMapper) ActionResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionResponse)

Example 7 with ActionResponseDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto in project open-smart-grid-platform by OSGP.

the class BundleServiceTest method shouldHandleActionsWithResultContainingFaultResponseWithRetryableException.

@Test
public void shouldHandleActionsWithResultContainingFaultResponseWithRetryableException() {
    final ActionResponseDto faultResponse = this.createFaultResponse(true);
    final BundleMessagesRequestDto bundleMessagesRequest = new BundleMessagesRequestDto(Arrays.asList(this.createAction(this.builder.makePeriodicMeterReadsRequestDataDto(), faultResponse)));
    final BundleMessagesRequestDto result = this.bundleService.callExecutors(null, new DlmsDevice(), bundleMessagesRequest, this.messageMetadata);
    verify(this.bundleCommandExecutorMap).getCommandExecutor(PeriodicMeterReadsRequestDataDto.class);
    assertThat(result.getAllResponses().size()).isOne();
    assertThat(result.getAllResponses().get(0)).isNotNull();
}
Also used : BundleMessagesRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto) ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Example 8 with ActionResponseDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto in project open-smart-grid-platform by OSGP.

the class BundleServiceTest method shouldNotHandleActionsContainingResult.

@Test
public void shouldNotHandleActionsContainingResult() {
    final ActionResponseDto previousActionResponse = new ActionResponseDto();
    final BundleMessagesRequestDto bundleMessagesRequest = new BundleMessagesRequestDto(Arrays.asList(this.createAction(this.builder.makePeriodicMeterReadsRequestDataDto(), previousActionResponse)));
    final BundleMessagesRequestDto result = this.bundleService.callExecutors(null, new DlmsDevice(), bundleMessagesRequest, this.messageMetadata);
    verify(this.bundleCommandExecutorMap, never()).getCommandExecutor(PeriodicMeterReadsRequestDataDto.class);
    assertThat(result.getAllResponses().size()).isOne();
    assertThat(result.getAllResponses().get(0)).isEqualTo(previousActionResponse);
}
Also used : BundleMessagesRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto) ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Example 9 with ActionResponseDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto in project open-smart-grid-platform by OSGP.

the class ClearAlarmRegisterCommandExecutorTest method testAsBundleResponse.

@Test
void testAsBundleResponse() throws ProtocolAdapterException {
    final ActionResponseDto responseDto = this.executor.asBundleResponse(AccessResultCode.SUCCESS);
    assertThat(responseDto.getResult()).isEqualTo(OsgpResultTypeDto.OK);
}
Also used : ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) Test(org.junit.jupiter.api.Test)

Aggregations

ActionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto)9 Test (org.junit.jupiter.api.Test)4 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 BundleMessagesRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto)2 ArrayList (java.util.ArrayList)1 ConfigurableMapper (ma.glasnost.orika.impl.ConfigurableMapper)1 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)1 DeviceKeyProcessAlreadyRunningException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.DeviceKeyProcessAlreadyRunningException)1 MissingExecutorException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.MissingExecutorException)1 NonRetryableException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NonRetryableException)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)1 ActionResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionResponse)1 BundleMessagesResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.BundleMessagesResponse)1 CoupleMbusDeviceByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)1 DecoupleMbusDeviceResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto)1 EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)1 FirmwareVersionGasResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionGasResponseDto)1 FirmwareVersionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionResponseDto)1 SetDeviceLifecycleStatusByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto)1