Skip to content
Snippets Groups Projects
Commit 28935725 authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Code refactoring.

parent ea655924
No related branches found
No related tags found
1 merge request!68Integration tests for Google Cloud Run (GONRG-1016)
Pipeline #12715 passed
...@@ -14,22 +14,21 @@ ...@@ -14,22 +14,21 @@
package org.opengroup.osdu.legal.middleware; package org.opengroup.osdu.legal.middleware;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.gson.Gson;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import javassist.NotFoundException;
import javax.inject.Inject;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException; import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException; import javax.validation.ValidationException;
import javax.inject.Inject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.google.gson.Gson;
import javassist.NotFoundException;
import javax.ws.rs.core.MediaType;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -39,19 +38,11 @@ import org.springframework.lang.NonNull; ...@@ -39,19 +38,11 @@ import org.springframework.lang.NonNull;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.opengroup.osdu.core.common.model.http.AppException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice @RestControllerAdvice
public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
...@@ -122,7 +113,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { ...@@ -122,7 +113,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
"An unknown error has occurred.")); "An unknown error has occurred."));
} }
@Override @Override
@NonNull @NonNull
protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(@NonNull HttpRequestMethodNotSupportedException e, protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(@NonNull HttpRequestMethodNotSupportedException e,
...@@ -145,7 +135,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { ...@@ -145,7 +135,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
"Validation failed.", e)); "Validation failed.", e));
} }
public ResponseEntity<Object> getErrorResponse(AppException e) { public ResponseEntity<Object> getErrorResponse(AppException e) {
String exceptionMsg = e.getError().getMessage(); String exceptionMsg = e.getError().getMessage();
......
...@@ -17,24 +17,23 @@ package org.opengroup.osdu.legal.middleware; ...@@ -17,24 +17,23 @@ package org.opengroup.osdu.legal.middleware;
import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice @RestControllerAdvice
public class GlobalOtherExceptionMapper { public class GlobalOtherExceptionMapper {
private GlobalExceptionMapper mapper; private GlobalExceptionMapper mapper;
public GlobalOtherExceptionMapper(GlobalExceptionMapper mapper) { public GlobalOtherExceptionMapper(GlobalExceptionMapper mapper) {
this.mapper = mapper; this.mapper = mapper;
} }
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
protected ResponseEntity<Object> handleGeneralException(Exception e) { protected ResponseEntity<Object> handleGeneralException(Exception e) {
return mapper.getErrorResponse( return mapper.getErrorResponse(
new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error.", new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error.",
"An unknown error has occurred.", e)); "An unknown error has occurred.", e));
} }
} }
...@@ -5,14 +5,10 @@ import static org.junit.Assert.assertNull; ...@@ -5,14 +5,10 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.opengroup.osdu.legal.util.Constants.DATA_PARTITION_ID; import static org.opengroup.osdu.legal.util.Constants.DATA_PARTITION_ID;
import com.sun.jersey.core.header.MediaTypes; import com.sun.jersey.api.client.ClientResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.sun.jersey.api.client.ClientResponse;
import java.util.Objects; import java.util.Objects;
import javax.ws.rs.core.MediaType;
import lombok.extern.java.Log; import lombok.extern.java.Log;
import org.junit.Test; import org.junit.Test;
......
...@@ -82,8 +82,6 @@ public class TestUtils { ...@@ -82,8 +82,6 @@ public class TestUtils {
String query, Map<String, String> headers) throws Exception { String query, Map<String, String> headers) throws Exception {
Client client = getClient(); Client client = getClient();
// client.setConnectTimeout(5000);
// client.setReadTimeout(30000);
WebResource webResource = client.resource(getApiPath(path + query)); WebResource webResource = client.resource(getApiPath(path + query));
final WebResource.Builder builder = webResource.getRequestBuilder(); final WebResource.Builder builder = webResource.getRequestBuilder();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment