use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto in project open-smart-grid-platform by OSGP.
the class BundleResponseMessageProcessorTest method technicalExceptionDetailsWithoutCauseOrMessageInFaultResponse.
@Test
public void technicalExceptionDetailsWithoutCauseOrMessageInFaultResponse() throws Exception {
final ComponentType component = ComponentType.PROTOCOL_DLMS;
final Exception exception = new TechnicalException(component, null, null);
final FaultResponseDto faultResponse = this.processor.faultResponseForException(exception, this.parameters, this.defaultMessage);
this.assertResponse(faultResponse, null, this.defaultMessage, component.name(), null, null, this.parameters);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto in project open-smart-grid-platform by OSGP.
the class BundleResponseMessageProcessorTest method exceptionDetailsAreIncludedInFaultResponse.
@Test
public void exceptionDetailsAreIncludedInFaultResponse() throws Exception {
final String message = "general exception";
final Exception exception = new RuntimeException(message);
final FaultResponseDto faultResponse = this.processor.faultResponseForException(exception, this.parameters, this.defaultMessage);
this.assertResponse(faultResponse, null, this.defaultMessage, this.defaultComponent.name(), exception.getClass().getName(), message, this.parameters);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto in project open-smart-grid-platform by OSGP.
the class BundleResponseMessageProcessorTest method technicalExceptionDetailsAreIncludedInFaultResponse.
@Test
public void technicalExceptionDetailsAreIncludedInFaultResponse() throws Exception {
final FunctionalExceptionType functionalException = FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION;
final ComponentType component = ComponentType.PROTOCOL_DLMS;
final String message = "java.net.ConnectException: Connection refused";
final Throwable cause = new RuntimeException(message);
final Exception exception = new FunctionalException(functionalException, component, cause);
this.parameters.add(new FaultResponseParameterDto("deviceIdentification", "ESIM9999999999999"));
final FaultResponseDto faultResponse = this.processor.faultResponseForException(exception, this.parameters, this.defaultMessage);
this.assertResponse(faultResponse, functionalException.getCode(), functionalException.name(), component.name(), cause.getClass().getName(), message, this.parameters);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto in project open-smart-grid-platform by OSGP.
the class BundleService method addFaultResponse.
private void addFaultResponse(final ActionDto action, final Exception exception, final String defaultMessage, final DlmsDevice device) {
final List<FaultResponseParameterDto> parameterList = new ArrayList<>();
final FaultResponseParameterDto deviceIdentificationParameter = new FaultResponseParameterDto(DEVICE_IDENTIFICATION, device.getDeviceIdentification());
parameterList.add(deviceIdentificationParameter);
final FaultResponseDto faultResponse = this.faultResponseForException(exception, parameterList, defaultMessage);
action.setResponse(faultResponse);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method exceptionDetailsWithDefaultComponentInFaultResponse.
@Test
public void exceptionDetailsWithDefaultComponentInFaultResponse() throws Exception {
final String message = "Unexpected null/unspecified value for M-Bus Capture Time";
final Exception exception = new ProtocolAdapterException(message);
this.parameters.add(new FaultResponseParameterDto("deviceIdentification", "ESIM1400000000123"));
this.parameters.add(new FaultResponseParameterDto("gasDeviceIdentification", "ESIMG140000000841"));
this.parameters.add(new FaultResponseParameterDto("channel", "3"));
final String defaultMessage = "Unable to handle request";
final FaultResponseDto faultResponse = this.bundleService.faultResponseForException(exception, this.parameters, defaultMessage);
this.assertResponse(faultResponse, null, defaultMessage, this.defaultComponent.name(), exception.getClass().getName(), message, this.parameters);
}
Aggregations