mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor ScalarTypeBaseDateTime, merge into ScalarTypeUtils both IsoJsonDateTimeParser and DecimalUtils
That is, merge the static util methods into ScalarTypeUtils
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.JsonConfig;
|
||||
import io.ebean.core.type.IsoJsonDateTimeParser;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Types;
|
||||
@@ -18,7 +18,7 @@ public class ScalarTypeCalendarTest {
|
||||
|
||||
Calendar instance = Calendar.getInstance();
|
||||
String asUtc = type.toJsonISO8601(instance);
|
||||
Calendar calendar = type.convertFromInstant(IsoJsonDateTimeParser.parseIso(asUtc)); //type.fromJsonISO8601(asUtc);
|
||||
Calendar calendar = type.convertFromInstant(ScalarTypeUtils.parseInstant(asUtc)); //type.fromJsonISO8601(asUtc);
|
||||
|
||||
assertThat(instance).isEqualTo(calendar);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.core.type.DecimalUtils;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -41,7 +41,7 @@ class ScalarTypeDurationWithNanosTest {
|
||||
@Test
|
||||
void testToJdbcType() throws Exception {
|
||||
Duration duration = Duration.ofSeconds(323, 1500000);
|
||||
BigDecimal bigDecimal = DecimalUtils.toDecimal(duration);
|
||||
BigDecimal bigDecimal = ScalarTypeUtils.toDecimal(duration);
|
||||
|
||||
Object val1 = type.toJdbcType(duration);
|
||||
Object val2 = type.toJdbcType(bigDecimal);
|
||||
@@ -53,7 +53,7 @@ class ScalarTypeDurationWithNanosTest {
|
||||
@Test
|
||||
void testToBeanType() throws Exception {
|
||||
Duration duration = Duration.ofSeconds(323, 1500000);
|
||||
BigDecimal bigDecimal = DecimalUtils.toDecimal(duration);
|
||||
BigDecimal bigDecimal = ScalarTypeUtils.toDecimal(duration);
|
||||
|
||||
Duration val1 = type.toBeanType(duration);
|
||||
Duration val2 = type.toBeanType(bigDecimal);
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.JsonConfig;
|
||||
import io.ebean.core.type.IsoJsonDateTimeParser;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@@ -123,7 +123,7 @@ public class ScalarTypeOffsetDateTimeTest {
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
String asJson = typeIso.toJsonISO8601(now);
|
||||
|
||||
OffsetDateTime value = typeIso.convertFromInstant(IsoJsonDateTimeParser.parseIso(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
OffsetDateTime value = typeIso.convertFromInstant(ScalarTypeUtils.parseInstant(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
assertThat(now).isEqualToIgnoringNanos(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.JsonConfig;
|
||||
import io.ebean.core.type.IsoJsonDateTimeParser;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@@ -18,7 +18,7 @@ public class ScalarTypeTimestampTest {
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
String asJson = typeIso.toJsonISO8601(now);
|
||||
|
||||
Timestamp value = typeIso.convertFromInstant(IsoJsonDateTimeParser.parseIso(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
Timestamp value = typeIso.convertFromInstant(ScalarTypeUtils.parseInstant(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
assertThat(now).isEqualTo(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.JsonConfig;
|
||||
import io.ebean.core.type.IsoJsonDateTimeParser;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -35,7 +35,7 @@ public class ScalarTypeUtilDateTest {
|
||||
Date now = new Date();
|
||||
String asJson = typeIso.toJsonISO8601(now);
|
||||
|
||||
Instant instant = IsoJsonDateTimeParser.parseIso(asJson);
|
||||
Instant instant = ScalarTypeUtils.parseInstant(asJson);
|
||||
Date value = new java.util.Date(instant.toEpochMilli()); // typeIso.fromJsonISO8601(asJson);
|
||||
assertThat(now).isEqualTo(value);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.JsonConfig;
|
||||
import io.ebean.core.type.IsoJsonDateTimeParser;
|
||||
import io.ebean.core.type.ScalarTypeUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@@ -125,7 +125,7 @@ public class ScalarTypeZonedDateTimeTest {
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
String asJson = typeIso.toJsonISO8601(now);
|
||||
|
||||
ZonedDateTime value = type.convertFromInstant(IsoJsonDateTimeParser.parseIso(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
ZonedDateTime value = type.convertFromInstant(ScalarTypeUtils.parseInstant(asJson)); //typeIso.fromJsonISO8601(asJson);
|
||||
assertThat(now).isEqualTo(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user