File tree 2 files changed +16
-3
lines changed
main/java/com/introproventures/graphql/jpa/query/schema
test/java/com/introproventures/graphql/jpa/query/schema
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -741,8 +741,7 @@ private Timestamp doConvert(Object input) {
741
741
if (input instanceof Long longInput ) {
742
742
return new Timestamp (longInput );
743
743
} else if (input instanceof String stringInput ) {
744
- Instant instant = DateTimeHelper .parseDate (stringInput );
745
- return Timestamp .from (instant );
744
+ return Optional .of (stringInput ).map (DateTimeHelper ::parseDate ).map (Timestamp ::from ).orElse (null );
746
745
} else if (input instanceof Timestamp timestampInput ) {
747
746
return timestampInput ;
748
747
} else if (input instanceof Date dateInput ) {
Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ public void string2ZonedDateTime() {
273
273
274
274
ZonedDateTime resultLDT = (ZonedDateTime ) result ;
275
275
276
- assert resultLDT .getDayOfMonth () == 05 ;
276
+ assert resultLDT .getDayOfMonth () == 5 ;
277
277
assert resultLDT .getMonth () == Month .AUGUST ;
278
278
assert resultLDT .getYear () == 2019 ;
279
279
assert resultLDT .getHour () == 13 ;
@@ -365,6 +365,20 @@ public void testTimestampParseDateValue() {
365
365
.isEqualTo (expected );
366
366
}
367
367
368
+ @ Test
369
+ public void testTimestampParseInvalidValue () {
370
+ //given
371
+ Coercing <?, ?> coercing = JavaScalars .of (Timestamp .class ).getCoercing ();
372
+
373
+ //when
374
+ var throwable = catchThrowable (() -> coercing .parseValue ("foobar" ));
375
+
376
+ //then
377
+ assertThat (throwable )
378
+ .isInstanceOf (CoercingParseValueException .class )
379
+ .hasMessageContaining ("Invalid value 'foobar' for Timestamp" );
380
+ }
381
+
368
382
@ Test
369
383
public void testTimestampSerializeDateValue () {
370
384
//given
You can’t perform that action at this time.
0 commit comments