@Test
  public void withDate() {
    final Date date = new Date();
    final ObjectId id = ObjectId.get();
    final GsonEntity entity = ImmutableGsonEntity.builder()
        .id(id)
        .prop1("prop11")
        .prop2("prop22")
        .date(new Date(date.getTime()))
        .build();

    repository.insert(entity).getUnchecked();

    check(collection.countDocuments()).is(1L);

    // Gson serialises Date using SimpleDateFormat, which loses milliseconds
    final Date expectedDate = Date.from(
        ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())
            .truncatedTo(ChronoUnit.SECONDS)
            .toInstant());
    final GsonEntity expected = ImmutableGsonEntity.builder().from(entity)
        .date(expectedDate)
        .build();

    final GsonEntity actual = repository.findAll().fetchAll().getUnchecked().get(0);
    check(expected).is(actual);

    final BsonDocument doc = collection.find().first();
    check(doc.keySet()).hasContentInAnyOrder("_id", "prop1", "prop_two", "date", "uuid");
    final String expectedDateAsString = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US).format(expectedDate);
    check(doc.get("date").asString().getValue()).is(expectedDateAsString);
    check(doc.get("_id").asObjectId().getValue()).is(id);
  }
Tests for repository using <a href="https://github.com/FasterXML/jackson">Jackson</a> library.

@see JacksonCodecs
mongo/test/org/immutables/mongo/fixture/GsonRepoTest.java