AudienceHistorian { @NonNull public List<TagGroupsMutation> getTagGroupHistory(long sinceDate) { synchronized (tagRecords) { return filterHistory(tagRecords, sinceDate); } } AudienceHistorian(@NonNull AirshipChannel channel, @NonNull NamedUser namedUser, @NonNull Clock clock); @NonNull List<TagGroupsMutation> getTagGroupHistory(long sinceDate); @NonNull List<AttributeMutation> getAttributeHistory(long sinceDate);  }
@Test public void getTagGroupHistory() { when(mockNamedUser.getId()).thenReturn("named-user-id"); clock.currentTimeMillis = 100; final TagGroupsMutation channelMutation = TagGroupsMutation.newSetTagsMutation("history-group", tagSet("tag", "tags")); channelTagListener.onTagGroupsMutationUploaded("channel-id", channelMutation); clock.currentTimeMillis = 200; final TagGroupsMutation namedUserMutation = TagGroupsMutation.newAddTagsMutation("history-group", tagSet("another-tag")); namedUserTagListener.onTagGroupsMutationUploaded("named-user-id", namedUserMutation); List<TagGroupsMutation> allMutations = new ArrayList<>(); allMutations.add(channelMutation); allMutations.add(namedUserMutation); assertEquals(allMutations, historian.getTagGroupHistory(100)); assertEquals(Collections.singletonList(namedUserMutation), historian.getTagGroupHistory(101)); clock.currentTimeMillis = 201; assertEquals(Collections.emptyList(), historian.getTagGroupHistory(201)); }
@Test public void getTagGroupHistoryDifferentNamedUser() { when(mockNamedUser.getId()).thenReturn("foo"); clock.currentTimeMillis = 100; TagGroupsMutation fooMutation = TagGroupsMutation.newAddTagsMutation("history-group", tagSet("another-tag")); namedUserTagListener.onTagGroupsMutationUploaded("foo", fooMutation); TagGroupsMutation barMutation = TagGroupsMutation.newAddTagsMutation("history-group", tagSet("another-tag")); namedUserTagListener.onTagGroupsMutationUploaded("bar", barMutation); assertEquals(Collections.singletonList(fooMutation), historian.getTagGroupHistory(0)); }