Skip to content

Commit

Permalink
Add test wrt #282
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 11, 2023
1 parent 2c352f7 commit 74a058b
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ static class MyDto224 {
public Duration getDuration() { return duration; }
}

// [datetime#282]
static class Bean282 {
@JsonFormat(pattern = "SECONDS")
public Duration duration;

public Bean282(Duration d) { duration = d; }
}

@Test
public void testSerializationAsTimestampNanoseconds01() throws Exception
{
Expand Down Expand Up @@ -361,9 +369,19 @@ protected ObjectMapper _mapperForPatternOverride(String pattern) {

// [datetime#224]
@Test
public void testDurationFormatOverride() throws Exception
public void testDurationFormatOverrideMinutes() throws Exception
{
assertEquals(a2q("{'mins':120}"),
WRITER.writeValueAsString(new MyDto224(Duration.ofHours(2))));
}

// [datetime#282]
@Test
public void testDurationFormatOverrideSeconds() throws Exception
{
final Duration maxDuration = Duration.ofSeconds(Long.MIN_VALUE);
assertEquals(a2q("{'duration':"+Long.MIN_VALUE+"}"),
WRITER.writeValueAsString(new Bean282(maxDuration)));
}

}

0 comments on commit 74a058b

Please sign in to comment.