@@ -36,6 +38,7 @@
*/
@TraceReactivePanacheMongoRepository
@Interceptor
+@Priority(Priorities.USER)
public class ReactivePanacheMongoRepositoryTraceInterceptor {
/*
*
diff --git a/src/test/java/it/pagopa/swclient/mil/CommonHeadersValidatorFilterTest.java b/src/test/java/it/pagopa/swclient/mil/CommonHeadersValidatorFilterTest.java
new file mode 100644
index 0000000..e395fa6
--- /dev/null
+++ b/src/test/java/it/pagopa/swclient/mil/CommonHeadersValidatorFilterTest.java
@@ -0,0 +1,85 @@
+/*
+ * CommonHeadersValidatorFilterTest.java
+ *
+ * 29 apr 2024
+ */
+package it.pagopa.swclient.mil;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+
+import io.quarkus.test.junit.QuarkusTest;
+import it.pagopa.swclient.mil.bean.HeaderParamName;
+import jakarta.ws.rs.BadRequestException;
+import jakarta.ws.rs.container.ContainerRequestContext;
+
+/**
+ *
+ * @author Antonio Tarricone
+ */
+@QuarkusTest
+class CommonHeadersValidatorFilterTest {
+ @Test
+ void given_request_when_requestIdAndVersionAreOk_then_noExcpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getHeaderString(HeaderParamName.REQUEST_ID)).thenReturn(UUID.randomUUID().toString());
+ when(context.getHeaderString(HeaderParamName.VERSION)).thenReturn("1.0");
+
+ assertDoesNotThrow(() -> new CommonHeadersValidatorFilter().filter(context));
+ }
+
+ @Test
+ void given_request_when_requestIdAndVersionAreNotSet_then_noExcpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+
+ assertDoesNotThrow(() -> new CommonHeadersValidatorFilter().filter(context));
+ }
+
+ @Test
+ void given_request_when_requestIdIsInvalidAndVersionIsValid_then_excpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getHeaderString(HeaderParamName.REQUEST_ID)).thenReturn("");
+ when(context.getHeaderString(HeaderParamName.VERSION)).thenReturn("1.0");
+
+ CommonHeadersValidatorFilter filter = new CommonHeadersValidatorFilter();
+ assertThrows(BadRequestException.class, () -> filter.filter(context));
+ }
+
+ @Test
+ void given_request_when_requestIdIsInvalidAndVersionIsNotSet_then_excpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getHeaderString(HeaderParamName.REQUEST_ID)).thenReturn("");
+
+ CommonHeadersValidatorFilter filter = new CommonHeadersValidatorFilter();
+ assertThrows(BadRequestException.class, () -> filter.filter(context));
+ }
+
+ @Test
+ void given_request_when_requestIdIsValidAndVersionIsInvalid_then_excpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getHeaderString(HeaderParamName.REQUEST_ID)).thenReturn(UUID.randomUUID().toString());
+ when(context.getHeaderString(HeaderParamName.VERSION)).thenReturn(new String(new byte[] {
+ 0
+ }));
+
+ CommonHeadersValidatorFilter filter = new CommonHeadersValidatorFilter();
+ assertThrows(BadRequestException.class, () -> filter.filter(context));
+ }
+
+ @Test
+ void given_request_when_requestIdIsNotSetAndVersionIsInvalid_then_excpetionMustBeThrown() {
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getHeaderString(HeaderParamName.VERSION)).thenReturn(new String(new byte[] {
+ 0
+ }));
+
+ CommonHeadersValidatorFilter filter = new CommonHeadersValidatorFilter();
+ assertThrows(BadRequestException.class, () -> filter.filter(context));
+ }
+}
diff --git a/src/test/java/it/pagopa/swclient/mil/MappedDiagnosticContextFilterTest.java b/src/test/java/it/pagopa/swclient/mil/MappedDiagnosticContextFilterTest.java
index a760468..b76b106 100644
--- a/src/test/java/it/pagopa/swclient/mil/MappedDiagnosticContextFilterTest.java
+++ b/src/test/java/it/pagopa/swclient/mil/MappedDiagnosticContextFilterTest.java
@@ -18,7 +18,6 @@
import io.quarkus.test.junit.QuarkusTest;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.core.MultivaluedHashMap;
-import jakarta.ws.rs.core.MultivaluedMap;
/**
*
diff --git a/src/test/java/it/pagopa/swclient/mil/RequestIdEchoFilterTest.java b/src/test/java/it/pagopa/swclient/mil/RequestIdEchoFilterTest.java
index e96d2c3..cbce43b 100644
--- a/src/test/java/it/pagopa/swclient/mil/RequestIdEchoFilterTest.java
+++ b/src/test/java/it/pagopa/swclient/mil/RequestIdEchoFilterTest.java
@@ -12,7 +12,6 @@
import java.io.IOException;
import java.util.List;
-import org.jboss.logging.MDC;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
diff --git a/src/test/java/it/pagopa/swclient/mil/bean/ErrorsTest.java b/src/test/java/it/pagopa/swclient/mil/bean/ErrorsTest.java
index b786cef..fd97c8b 100644
--- a/src/test/java/it/pagopa/swclient/mil/bean/ErrorsTest.java
+++ b/src/test/java/it/pagopa/swclient/mil/bean/ErrorsTest.java
@@ -6,7 +6,6 @@
package it.pagopa.swclient.mil.bean;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import java.util.List;
@@ -20,15 +19,6 @@
*/
@QuarkusTest
class ErrorsTest {
- /**
- *
- */
- @Test
- void given_listOfErrorsWithoutDescription_when_getList_then_returnGivenList() {
- List