use of org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto in project open-smart-grid-platform by OSGP.
the class BundleResponseMessageProcessor method handleError.
@Override
protected void handleError(final Exception e, final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage) throws FunctionalException {
final OsgpException osgpException = this.ensureOsgpException(e);
final BundleMessagesRequestDto bundleMessagesResponseDto = (BundleMessagesRequestDto) responseMessage.getDataObject();
final List<ActionDto> actionList = bundleMessagesResponseDto.getActionList();
for (final ActionDto action : actionList) {
if (action.getResponse() == null) {
final List<FaultResponseParameterDto> parameterList = new ArrayList<>();
final FaultResponseParameterDto deviceIdentificationParameter = new FaultResponseParameterDto("deviceIdentification", deviceMessageMetadata.getDeviceIdentification());
parameterList.add(deviceIdentificationParameter);
action.setResponse(this.faultResponseForException(e, parameterList, "Unable to handle request"));
}
}
this.bundleService.handleBundleResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, bundleMessagesResponseDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto 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();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto 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);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method testException.
@Test
public void testException() {
final List<ActionDto> actionDtoList = this.makeActions();
final BundleMessagesRequestDto dto = new BundleMessagesRequestDto(actionDtoList);
this.getStub(FindEventsRequestDto.class).failWith(new ProtocolAdapterException("simulate error"));
final BundleMessagesRequestDto result = this.callExecutors(dto, this.messageMetadata);
this.assertResult(result);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method testHappyFlow.
@Test
public void testHappyFlow() {
final List<ActionDto> actionDtoList = this.makeActions();
final BundleMessagesRequestDto dto = new BundleMessagesRequestDto(actionDtoList);
final BundleMessagesRequestDto result = this.callExecutors(dto, this.messageMetadata);
this.assertResult(result);
}
Aggregations