diff --git a/marketplace-service/src/test/java/com/axonivy/market/util/LoggingUtilsTest.java b/marketplace-service/src/test/java/com/axonivy/market/util/LoggingUtilsTest.java index be0ad64f..b2ba2f6f 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/util/LoggingUtilsTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/util/LoggingUtilsTest.java @@ -6,9 +6,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import java.text.SimpleDateFormat; import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.Map; @ExtendWith(MockitoExtension.class) @@ -68,11 +67,12 @@ void testGetCurrentDate() { @Test void testGetCurrentTimestamp() { - String expectedTimestamp = LocalDateTime.now() - .format(DateTimeFormatter.ofPattern(LoggingConstants.TIMESTAMP_FORMAT)); - String actualTimestamp = LoggingUtils.getCurrentTimestamp(); - Assertions.assertEquals(expectedTimestamp.substring(0, 19), actualTimestamp.substring(0, 19), - "The returned timestamp does not match the expected format or value"); + String timestamp = LoggingUtils.getCurrentTimestamp(); + Assertions.assertNotNull(timestamp, "Timestamp should not be null"); + SimpleDateFormat dateFormat = new SimpleDateFormat(LoggingConstants.TIMESTAMP_FORMAT); + Assertions.assertDoesNotThrow(() -> { + dateFormat.parse(timestamp); + }, "Timestamp does not match the expected format"); } }