diff --git a/code/gms-backend/src/main/java/io/github/gms/common/dto/ErrorResponseDto.java b/code/gms-backend/src/main/java/io/github/gms/common/dto/ErrorResponseDto.java index ad90ee45..2a644fa8 100644 --- a/code/gms-backend/src/main/java/io/github/gms/common/dto/ErrorResponseDto.java +++ b/code/gms-backend/src/main/java/io/github/gms/common/dto/ErrorResponseDto.java @@ -1,11 +1,15 @@ package io.github.gms.common.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serial; import java.io.Serializable; import java.time.ZonedDateTime; +import static io.github.gms.common.util.Constants.DATE_FORMAT; + /** * @author Peter Szrnka * @since 1.0 @@ -14,10 +18,12 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class ErrorResponseDto implements Serializable { + @Serial private static final long serialVersionUID = 6418018474049813605L; private String correlationId; private String message; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT) private ZonedDateTime timestamp; public ErrorResponseDto(String message, String correlationId, ZonedDateTime timestamp) { diff --git a/code/gms-backend/src/test/java/io/github/gms/GmsExceptionHandlerTest.java b/code/gms-backend/src/test/java/io/github/gms/GmsExceptionHandlerTest.java index 87a77c08..59711975 100644 --- a/code/gms-backend/src/test/java/io/github/gms/GmsExceptionHandlerTest.java +++ b/code/gms-backend/src/test/java/io/github/gms/GmsExceptionHandlerTest.java @@ -6,7 +6,6 @@ import io.github.gms.common.exception.GmsException; import org.jboss.logging.MDC; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.http.HttpStatus; @@ -29,7 +28,6 @@ * @author Peter Szrnka * @since 1.0 */ -@Disabled class GmsExceptionHandlerTest extends AbstractUnitTest { private static final String CORRELATION_ID = "CORRELATION_ID"; @@ -101,7 +99,7 @@ void shouldHandleMissingRequestHeaderException() { WebRequest webRequest = mock(WebRequest.class); // act - ResponseEntity response = handler.handleOtherException(new MissingRequestHeaderException("x-api-key", mockMethodParameter), webRequest); + ResponseEntity response = handler.handleMissingRequestHeaderException(new MissingRequestHeaderException("x-api-key", mockMethodParameter), webRequest); // assert assertNotNull(response); diff --git a/code/gms-backend/src/test/java/io/github/gms/TestApplicationConfig.java b/code/gms-backend/src/test/java/io/github/gms/TestApplicationConfig.java index 42e0e1c7..0a0ead6d 100644 --- a/code/gms-backend/src/test/java/io/github/gms/TestApplicationConfig.java +++ b/code/gms-backend/src/test/java/io/github/gms/TestApplicationConfig.java @@ -5,6 +5,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; /** @@ -13,6 +14,7 @@ */ @Slf4j @Configuration +@ComponentScan(basePackages = "io.github.gms") public class TestApplicationConfig { @Bean