BundleResponseMessageProcessor extends OsgpCoreResponseMessageProcessor { protected FaultResponseDto faultResponseForException(final Exception exception, final List<FaultResponseParameterDto> parameters, final String defaultMessage) { final FaultResponseParametersDto faultResponseParameters = this.faultResponseParametersForList(parameters); if (exception instanceof FunctionalException || exception instanceof TechnicalException) { return this.faultResponseForFunctionalOrTechnicalException((OsgpException) exception, faultResponseParameters, defaultMessage); } return new FaultResponseDto.Builder().withMessage(defaultMessage) .withComponent(ComponentType.DOMAIN_SMART_METERING.name()) .withInnerException(exception.getClass().getName()).withInnerMessage(exception.getMessage()) .withFaultResponseParameters(faultResponseParameters).build(); } @Autowired  BundleResponseMessageProcessor(
            WebServiceResponseMessageSender responseMessageSender,
            @Qualifier("domainSmartMeteringOsgpCoreResponseMessageProcessorMap") MessageProcessorMap messageProcessorMap);   }
@Test public void functionalExceptionDetailsAreIncludedInFaultResponse() throws Exception { final FunctionalExceptionType functionalException = FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION; final ComponentType component = ComponentType.DOMAIN_SMART_METERING; final String message = "No Action Value Response Object for Action Value Response DTO Object of class: org.opensmartgridplatform.dto.valueobjects.smartmetering.NonExistentResponseDto"; final Throwable cause = new RuntimeException(message); final Exception exception = new FunctionalException(functionalException, component, cause); final FaultResponseDto faultResponse = this.processor.faultResponseForException(exception, null, this.defaultMessage); this.assertResponse(faultResponse, functionalException.getCode(), functionalException.name(), component.name(), cause.getClass().getName(), message, this.parameters); }
@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); }
@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); }
@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); }