PendingTagGroupMutationStore extends JsonDataStoreQueue<TagGroupsMutation> { void collapseAndSaveMutations() { apply(new Function<List<TagGroupsMutation>, List<TagGroupsMutation>>() { @Override public List<TagGroupsMutation> apply(List<TagGroupsMutation> input) { return TagGroupsMutation.collapseMutations(input); } }); } PendingTagGroupMutationStore(PreferenceDataStore dataStore, String storeKey);   }
@Test public void testCollapse() { List<TagGroupsMutation> mutations = new ArrayList<>(); mutations.add(TagGroupsMutation.newAddTagsMutation("group-one", createTagSet("cool"))); mutations.add(TagGroupsMutation.newAddTagsMutation("group-two", createTagSet("whatever"))); store.addAll(mutations); store.collapseAndSaveMutations(); List<TagGroupsMutation> collapseMutations = TagGroupsMutation.collapseMutations(mutations); assertEquals(collapseMutations.get(0), store.peek()); }