Skip to content

Commit

Permalink
MARP-1548 Suspicious numbers in installation count - Fix unstable test
Browse files Browse the repository at this point in the history
  • Loading branch information
quanpham-axonivy committed Dec 19, 2024
1 parent 28eb978 commit e781fda
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
}

}

0 comments on commit e781fda

Please sign in to comment.