ScroballDB { public void writeScrobble(Scrobble scrobble) { Track track = scrobble.track(); ScrobbleStatus status = scrobble.status(); ScrobbleLogEntry logEntry = new ScrobbleLogEntry(); logEntry.timestamp = scrobble.timestamp(); logEntry.artist = track.artist(); logEntry.track = track.track(); logEntry.status = scrobble.status().getErrorCode(); if (track.album().isPresent()) { logEntry.album = track.album().get(); } if (track.albumArtist().isPresent()) { logEntry.albumArtist = track.albumArtist().get(); } if (status.getDbId() > -1) { logEntry.id = status.getDbId(); } logEntry.save(); scrobble.status().setDbId(logEntry.id); eventBus.post(ScroballDBUpdateEvent.create(scrobble)); }  List<Scrobble> readScrobbles(); void writeScrobble(Scrobble scrobble); void writeScrobbles(List<Scrobble> scrobbles); List<Scrobble> readPendingScrobbles(); void writePendingPlaybackItem(PlaybackItem playbackItem); List<PlaybackItem> readPendingPlaybackItems(); void clearPendingPlaybackItems(); List<LovedTracksEntry> readPendingLoves(); LovedTracksEntry writeLove(Track track, int status); boolean isLoved(Track track); void prune(); void clear();  }
@Test public void write_setsDbIdOnNewEntries() { assertThat(scrobble.status().getDbId()).isEqualTo(-1); scroballDB.writeScrobble(scrobble); assertThat(scrobble.status().getDbId()).isGreaterThan(0L); }