Handle a null timestamp in local/first actions (#6379)
This commit is contained in:
parent
0bdf9d9e28
commit
e0227f9b16
|
@ -70,7 +70,8 @@ public class EpisodeActionFilter {
|
|||
EpisodeAction secondAction) {
|
||||
return secondAction != null
|
||||
&& secondAction.getTimestamp() != null
|
||||
&& secondAction.getTimestamp().after(firstAction.getTimestamp());
|
||||
&& (firstAction.getTimestamp() == null
|
||||
|| secondAction.getTimestamp().after(firstAction.getTimestamp()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -184,4 +184,29 @@ public class EpisodeActionFilterTest extends TestCase {
|
|||
.getRemoteActionsOverridingLocalActions(remoteActions, episodeActions);
|
||||
assertEquals(0, uniqueList.size());
|
||||
}
|
||||
|
||||
public void testPresentRemoteTimestampOverridesMissingLocalTimestamp() throws ParseException {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date arbitraryTime = format.parse("2021-01-01 08:00:00");
|
||||
|
||||
List<EpisodeAction> episodeActions = new ArrayList<>();
|
||||
episodeActions.add(new EpisodeAction
|
||||
.Builder("podcast.a", "episode.1", EpisodeAction.Action.PLAY)
|
||||
// no timestamp
|
||||
.position(10)
|
||||
.build()
|
||||
);
|
||||
|
||||
List<EpisodeAction> remoteActions = new ArrayList<>();
|
||||
remoteActions.add(new EpisodeAction
|
||||
.Builder("podcast.a", "episode.1", EpisodeAction.Action.PLAY)
|
||||
.timestamp(arbitraryTime)
|
||||
.position(10)
|
||||
.build()
|
||||
);
|
||||
|
||||
Map<Pair<String, String>, EpisodeAction> uniqueList = episodeActionFilter
|
||||
.getRemoteActionsOverridingLocalActions(remoteActions, episodeActions);
|
||||
assertSame(1, uniqueList.size());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue