Skip to content

Commit a385e6b

Browse files
committed
Fix test timezone
1 parent 8f548af commit a385e6b

File tree

1 file changed

+37
-31
lines changed

1 file changed

+37
-31
lines changed

src/test/java/de/zalando/typemapper/postgres/PgSerializerTest.java

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package de.zalando.typemapper.postgres;
22

33
import java.sql.SQLException;
4-
import java.time.Instant;
5-
import java.time.format.DateTimeFormatter;
4+
import java.time.LocalDateTime;
5+
import java.time.ZoneId;
66
import java.util.Arrays;
77
import java.util.Collection;
88
import java.util.Date;
@@ -43,9 +43,9 @@ public PgSerializerTest(final Object objectToSerialize, final Object expected) {
4343
this.expectedString = null;
4444
this.expectedPattern = (Pattern) expected;
4545
} else {
46-
throw new IllegalArgumentException(String.format(
47-
"Expected either a String or a Pattern, got: %s (%s)",
48-
expected, expected == null ? null : expected.getClass()));
46+
throw new IllegalArgumentException(String.format(
47+
"Expected either a String or a Pattern, got: %s (%s)",
48+
expected, expected == null ? null : expected.getClass()));
4949
}
5050
}
5151

@@ -58,33 +58,39 @@ public PgSerializerTest(final Object objectToSerialize, final Object expected) {
5858
@SuppressWarnings("deprecation")
5959
@Parameters
6060
public static Collection<Object[]> generateData() throws SQLException {
61+
6162
return Arrays.asList(
62-
new Object[][] {
63-
{new Date(112, 11, 1, 6, 6, 6), Pattern.compile("2012-12-01 06:06:06[+-]?\\d{2}")},
64-
{new Date(112, 9, 1, 6, 6, 6), Pattern.compile("2012-10-01 06:06:06[+-]?\\d{2}")},
65-
{Date.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse("2017-05-14T12:34:56.123456789+02:00", Instant::from)), Pattern.compile("2017-05-14 12:34:56.123000[+-]?\\d{2}")},
66-
{1, "1"},
67-
{69, "69"},
68-
{true, "t"},
69-
{new int[] {1, 2, 3, 4}, "{1,2,3,4}"},
70-
{new Integer[] {null, 2, 3, 4}, "{NULL,2,3,4}"},
71-
{ARRAY("a", "b").asJdbcArray("text"), "{a,b}"},
72-
{ARRAY("a", "b(x)").asJdbcArray("text"), "{a,b(x)}"},
73-
{ARRAY("a", "b{x}").asJdbcArray("text"), "{a,\"b{x}\"}"},
74-
{
75-
ARRAY("first element", "second \"quoted\" element").asJdbcArray("text"),
76-
"{\"first element\",\"second \\\"quoted\\\" element\"}"
77-
},
78-
{ROW(1, 2), "(1,2)"},
79-
{ROW("a", "b{x}"), "(a,b{x})"},
80-
{ROW("a", "b(x)"), "(a,\"b(x)\")"},
81-
{ROW(1, 2, ARRAY("a", "b")), "(1,2,\"{a,b}\")"},
82-
{ROW("a", "b", new int[] {1, 2, 3, 4}), "(a,b,\"{1,2,3,4}\")"},
83-
{ROW("a", null, ARRAY(ROW(1), ROW(2), null)), "(a,,\"{(1),(2),NULL}\")"},
84-
{
85-
ROW("a", null, ARRAY(ROW(1, 11), ROW(2, 22), null)),
86-
"(a,,\"{\"\"(1,11)\"\",\"\"(2,22)\"\",NULL}\")"
87-
},
63+
new Object[][]{
64+
{new Date(112, 11, 1, 6, 6, 6), Pattern.compile("2012-12-01 06:06:06[+-]?\\d{2}")},
65+
{new Date(112, 9, 1, 6, 6, 6), Pattern.compile("2012-10-01 06:06:06[+-]?\\d{2}")},
66+
{Date.from(
67+
LocalDateTime.of(2017, 5, 14, 12, 34, 56, 123456789)
68+
.atZone(ZoneId.systemDefault())
69+
.toInstant()
70+
),
71+
Pattern.compile("2017-05-14 12:34:56.123000[+-]?\\d{2}")},
72+
{1, "1"},
73+
{69, "69"},
74+
{true, "t"},
75+
{new int[]{1, 2, 3, 4}, "{1,2,3,4}"},
76+
{new Integer[]{null, 2, 3, 4}, "{NULL,2,3,4}"},
77+
{ARRAY("a", "b").asJdbcArray("text"), "{a,b}"},
78+
{ARRAY("a", "b(x)").asJdbcArray("text"), "{a,b(x)}"},
79+
{ARRAY("a", "b{x}").asJdbcArray("text"), "{a,\"b{x}\"}"},
80+
{
81+
ARRAY("first element", "second \"quoted\" element").asJdbcArray("text"),
82+
"{\"first element\",\"second \\\"quoted\\\" element\"}"
83+
},
84+
{ROW(1, 2), "(1,2)"},
85+
{ROW("a", "b{x}"), "(a,b{x})"},
86+
{ROW("a", "b(x)"), "(a,\"b(x)\")"},
87+
{ROW(1, 2, ARRAY("a", "b")), "(1,2,\"{a,b}\")"},
88+
{ROW("a", "b", new int[]{1, 2, 3, 4}), "(a,b,\"{1,2,3,4}\")"},
89+
{ROW("a", null, ARRAY(ROW(1), ROW(2), null)), "(a,,\"{(1),(2),NULL}\")"},
90+
{
91+
ROW("a", null, ARRAY(ROW(1, 11), ROW(2, 22), null)),
92+
"(a,,\"{\"\"(1,11)\"\",\"\"(2,22)\"\",NULL}\")"
93+
},
8894
});
8995
}
9096

0 commit comments

Comments
 (0)