From e781fdae6050ea549385bb8ae03021cb6ab08ab0 Mon Sep 17 00:00:00 2001 From: "AAVN\\pvquan" Date: Thu, 19 Dec 2024 18:02:25 +0700 Subject: [PATCH] MARP-1548 Suspicious numbers in installation count - Fix unstable test --- .../com/axonivy/market/util/LoggingUtilsTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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"); } }