Search in sources :

Example 1 with FaultResponseDto

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);
}
Also used : ComponentType(org.opensmartgridplatform.shared.exceptionhandling.ComponentType) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FaultResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Test(org.junit.jupiter.api.Test)

Example 2 with FaultResponseDto

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);
}
Also used : FaultResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Test(org.junit.jupiter.api.Test)

Example 3 with FaultResponseDto

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);
}
Also used : ComponentType(org.opensmartgridplatform.shared.exceptionhandling.ComponentType) FaultResponseParameterDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseParameterDto) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) FaultResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto) FunctionalExceptionType(org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Test(org.junit.jupiter.api.Test)

Example 4 with FaultResponseDto

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);
}
Also used : FaultResponseParameterDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseParameterDto) ArrayList(java.util.ArrayList) FaultResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto)

Example 5 with FaultResponseDto

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);
}
Also used : FaultResponseParameterDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseParameterDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) FaultResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException) Test(org.junit.jupiter.api.Test)

Aggregations

FaultResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseDto)6 Test (org.junit.jupiter.api.Test)5 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)4 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 FaultResponseParameterDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FaultResponseParameterDto)3 ComponentType (org.opensmartgridplatform.shared.exceptionhandling.ComponentType)3 FunctionalExceptionType (org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType)2 ArrayList (java.util.ArrayList)1 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1