Skip to content

Commit

Permalink
Improving failure format on some functions.
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 3, 2023
1 parent 8894435 commit d6b6aab
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ExprDateValue(String date) {
this.date = LocalDate.parse(date, DATE_TIME_FORMATTER_VARIABLE_NANOS_OPTIONAL);
} catch (DateTimeParseException e) {
throw new SemanticCheckException(
String.format("date:%s in unsupported format, please use yyyy-MM-dd", date));
String.format("date:%s in unsupported format, please use 'yyyy-MM-dd'", date));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ExprDatetimeValue(String datetime) {
} catch (DateTimeParseException e) {
throw new SemanticCheckException(
String.format(
"datetime:%s in unsupported format, please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"datetime:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
datetime));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public LocalDateTime datetimeValue() {
} catch (SemanticCheckException exception) {
throw new SemanticCheckException(
String.format(
"datetime:%s in unsupported format, please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"datetime:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ExprTimeValue(String time) {
} catch (DateTimeParseException e) {
throw new SemanticCheckException(
String.format(
"time:%s in unsupported format, please use " + "HH:mm:ss[.SSSSSSSSS]", time));
"time:%s in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'", time));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ExprTimestampValue(String timestamp) {
} catch (DateTimeParseException e) {
throw new SemanticCheckException(
String.format(
"timestamp:%s in unsupported format, please " + "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"timestamp:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
timestamp));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public void datetimeValueInterfaceTest() {
public void dateInUnsupportedFormat() {
SemanticCheckException exception =
assertThrows(SemanticCheckException.class, () -> new ExprDateValue("2020-07-07Z"));
assertEquals("date:2020-07-07Z in unsupported format, please use yyyy-MM-dd",
assertEquals("date:2020-07-07Z in unsupported format, please use 'yyyy-MM-dd'",
exception.getMessage());
}

@Test
public void timeInUnsupportedFormat() {
SemanticCheckException exception =
assertThrows(SemanticCheckException.class, () -> new ExprTimeValue("01:01:0"));
assertEquals("time:01:01:0 in unsupported format, please use HH:mm:ss[.SSSSSSSSS]",
assertEquals("time:01:01:0 in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -125,7 +125,7 @@ public void timestampInUnsupportedFormat() {
() -> new ExprTimestampValue("2020-07-07T01:01:01Z"));
assertEquals(
"timestamp:2020-07-07T01:01:01Z in unsupported format, "
+ "please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
+ "please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -136,7 +136,7 @@ public void datetimeInUnsupportedFormat() {
() -> new ExprDatetimeValue("2020-07-07T01:01:01Z"));
assertEquals(
"datetime:2020-07-07T01:01:01Z in unsupported format, "
+ "please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
+ "please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -154,7 +154,7 @@ public void stringDateTimeValue() {
() -> new ExprStringValue("2020-07-07T01:01:01Z").datetimeValue());
assertEquals(
"datetime:2020-07-07T01:01:01Z in unsupported format, "
+ "please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
+ "please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -169,7 +169,7 @@ public void stringDateValue() {
SemanticCheckException exception =
assertThrows(SemanticCheckException.class,
() -> new ExprStringValue("2020-07-07Z").dateValue());
assertEquals("date:2020-07-07Z in unsupported format, please use yyyy-MM-dd",
assertEquals("date:2020-07-07Z in unsupported format, please use 'yyyy-MM-dd'",
exception.getMessage());
}

Expand All @@ -183,7 +183,7 @@ public void stringTimeValue() {
SemanticCheckException exception =
assertThrows(SemanticCheckException.class,
() -> new ExprStringValue("01:01:0").timeValue());
assertEquals("time:01:01:0 in unsupported format, please use HH:mm:ss[.SSSSSSSSS]",
assertEquals("time:01:01:0 in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand Down Expand Up @@ -250,8 +250,8 @@ public void timestampOverMaxNanoPrecision() {
assertThrows(SemanticCheckException.class,
() -> new ExprTimestampValue("2020-07-07 01:01:01.1234567890"));
assertEquals(
"timestamp:2020-07-07 01:01:01.1234567890 in unsupported format, "
+ "please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"timestamp:2020-07-07 01:01:01.1234567890 in unsupported format, please use " +
"'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -262,7 +262,7 @@ public void datetimeOverMaxNanoPrecision() {
() -> new ExprDatetimeValue("2020-07-07 01:01:01.1234567890"));
assertEquals(
"datetime:2020-07-07 01:01:01.1234567890 in unsupported format, "
+ "please use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
+ "please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}

Expand All @@ -272,7 +272,7 @@ public void timeOverMaxNanoPrecision() {
assertThrows(SemanticCheckException.class,
() -> new ExprTimeValue("01:01:01.1234567890"));
assertEquals(
"time:01:01:01.1234567890 in unsupported format, please use HH:mm:ss[.SSSSSSSSS]",
"time:01:01:01.1234567890 in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'",
exception.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void timestamp_one_arg_string_invalid_format(String value, String testNam
var exception = assertThrows(SemanticCheckException.class,
() -> DSL.timestamp(functionProperties, DSL.literal(value)).valueOf());
assertEquals(String.format("timestamp:%s in unsupported format, please "
+ "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]", value), exception.getMessage());
+ "use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'", value), exception.getMessage());
}

@Test
Expand Down

0 comments on commit d6b6aab

Please sign in to comment.