This commit is contained in:
Tour
2025-12-08 11:43:46 +01:00
parent 19a538d27a
commit 1ac3c46c75
4 changed files with 21 additions and 8 deletions

BIN
empty_test_1765183292551.db Normal file

Binary file not shown.

View File

@@ -132,14 +132,7 @@ public class AuctionRepository {
.bind("country", countryCode)
.map((rs, ctx) -> {
var closingStr = rs.getString("closing_time");
LocalDateTime closingTime = null;
if (closingStr != null && !closingStr.isBlank()) {
try {
closingTime = LocalDateTime.parse(closingStr);
} catch (Exception e) {
log.warn("Invalid closing_time format: {}", closingStr);
}
}
LocalDateTime closingTime = auctiora.ScraperDataAdapter.parseTimestamp(closingStr);
return new AuctionInfo(
rs.getLong("auction_id"),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -6,6 +6,8 @@ import org.junit.jupiter.api.DisplayName;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.Instant;
import java.time.ZoneId;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
@@ -228,6 +230,24 @@ class ScraperDataAdapterTest {
assertEquals("GBP", lot.currency());
}
@Test
@DisplayName("Should parse epoch seconds timestamp")
void testParseEpochSeconds() {
long seconds = 1765994400L;
LocalDateTime expected = LocalDateTime.ofInstant(Instant.ofEpochSecond(seconds), ZoneId.systemDefault());
LocalDateTime parsed = ScraperDataAdapter.parseTimestamp(String.valueOf(seconds));
assertEquals(expected, parsed);
}
@Test
@DisplayName("Should parse epoch milliseconds timestamp")
void testParseEpochMillis() {
long millis = 1765994400000L;
LocalDateTime expected = LocalDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneId.systemDefault());
LocalDateTime parsed = ScraperDataAdapter.parseTimestamp(String.valueOf(millis));
assertEquals(expected, parsed);
}
// Helper methods
private ResultSet createLotResultSet(String bidAmount) throws SQLException {