|
24 | 24 | import org.junit.jupiter.api.TestInstance.Lifecycle; |
25 | 25 | import org.testcontainers.containers.JdbcDatabaseContainer; |
26 | 26 |
|
| 27 | +import java.math.BigDecimal; |
27 | 28 | import java.util.List; |
28 | 29 | import java.util.Optional; |
29 | 30 |
|
@@ -117,16 +118,17 @@ void testFindDistribution() |
117 | 118 | @Test |
118 | 119 | void testTimestampParsing() |
119 | 120 | { |
120 | | - long result = 30338640; |
121 | | - |
122 | | - // postgres: minute -> {Double@9333} 3.033864E7 |
123 | | - String postgresTimestamp = "3.033864E7"; |
124 | | - long parsedLongTimestamp = (long) Float.parseFloat(postgresTimestamp); |
125 | | - assertThat(parsedLongTimestamp).isEqualTo(result); |
126 | | - |
127 | | - // mysql: minute -> {BigDecimal@9775} "30338640" |
128 | | - String mysqlTimestamp = "30338640"; |
129 | | - long parsedLongTimestamp2 = (long) Float.parseFloat(mysqlTimestamp); |
130 | | - assertThat(parsedLongTimestamp2).isEqualTo(result); |
| 121 | + // This ensures odd-minute values remain precision when converted from different formats. |
| 122 | + long expectedMinuteBucket = 30338641; |
| 123 | + |
| 124 | + // postgres: minute -> {Double@9333} 3.0338641E7 |
| 125 | + String postgresTimestamp = "3.0338641E7"; |
| 126 | + long parsedPostgresMinute = new BigDecimal(postgresTimestamp).longValue(); |
| 127 | + assertThat(parsedPostgresMinute).isEqualTo(expectedMinuteBucket); |
| 128 | + |
| 129 | + // mysql: minute -> {BigDecimal@9775} "30338641" |
| 130 | + String mysqlTimestamp = "30338641"; |
| 131 | + long parsedMysqlMinute = new BigDecimal(mysqlTimestamp).longValue(); |
| 132 | + assertThat(parsedMysqlMinute).isEqualTo(expectedMinuteBucket); |
131 | 133 | } |
132 | 134 | } |
0 commit comments