Snapshot { public static Builder builder(Instant time, Snapshot other) { return new Builder(time, other); } @SuppressWarnings("unused") private  Snapshot();  Snapshot(Instant time); Optional<Long> getId(); Optional<Long> getEventId(); Instant getSnapshotTime(); TeamTagMap getTeamTagMap(); Instant getStartTime(); Instant getEndTime(); TeamStates getTeamStates(); TeamStates getPublicTeamStates(); String getStatusMessage(); Status getStatus(); int getUpdateFrequency(); static Builder builder(Instant time, Snapshot other); static Optional<Snapshot> loadForEvent(Connection connection, Event event); static Optional<Snapshot> loadLatest(Connection connection); static Optional<Snapshot> loadBefore(Connection connection, Instant time); void save(Connection connection); static void deleteAfter(Connection connection, Snapshot snapshot);  }
@Test public void testSerializeToJson_DefaultObject() throws Exception { Snapshot snapshot = Snapshot.builder(Instant.EPOCH, null) .withStartTime(Instant.EPOCH) .withEndTime(Instant.EPOCH) .build(); MatcherAssert.assertThat(objectMapper.writeValueAsString(snapshot), SameJSONAs.sameJSONAs("{snapshotTime:0,startTime:0,endTime:0,teamTagMap:{}," + "teamStates:{},publicTeamStates:{},statusMessage:\"\",status:NoResults,updateFrequency:3}")); }
@Test public void testSerializeToJson_ComplexerObject() throws Exception { Snapshot snapshot = Snapshot.builder(Instant.EPOCH, null) .withStartTime(Instant.EPOCH) .withEndTime(Instant.EPOCH) .withTeamStates(new TeamStates() .setStateForTeam(0, new TeamState().addTagSeenEvent( new Snapshot(Instant.EPOCH), new TagSeenEvent(Instant.EPOCH, new TagId("ABCD"), 0, 0L)) .addTagSeenEvent(null, new TagSeenEvent(Instant.EPOCH.plus(1000, ChronoUnit.SECONDS), new TagId("ABCD"), 0, 1L)))) .withTeamTagMap(new TeamTagMap() .addTagToTeam("ABCD", 0)) .withStatusMessage("foo").build(); MatcherAssert.assertThat(objectMapper.writeValueAsString(snapshot), SameJSONAs.sameJSONAs("{\"snapshotTime\":0,statusMessage:foo,\"startTime\":0,\"endTime\":0,\"teamTagMap\":{\"0\":[\"ABCD\"]}," + "\"teamStates\":{\"0\":{\"lastTagSeenEvent\":{\"type\":\"TagSeen\",\"time\":1000," + "\"tag\":\"ABCD\",\"readerId\":0}, \"tagFragmentCount\":3}}}").allowingExtraUnexpectedFields()); }