@Test public void merge_excludeBadGroupId() { SignalGroupV1Record badRemote = new SignalGroupV1Record.Builder(byteArray(1), badGroupKey(99)) .setBlocked(false) .setProfileSharingEnabled(true) .setArchived(true) .build(); SignalGroupV1Record goodRemote = new SignalGroupV1Record.Builder(byteArray(1), groupKey(99)) .setBlocked(false) .setProfileSharingEnabled(true) .setArchived(true) .build(); Collection<SignalGroupV1Record> invalid = new GroupV1ConflictMerger(Collections.emptyList()).getInvalidEntries(Arrays.asList(badRemote, goodRemote)); assertEquals(Collections.singletonList(badRemote), invalid); }
@Override public @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords) { return Stream.of(remoteRecords) .filterNot(GroupV1ConflictMerger::isValidGroupId) .toList(); }
GroupV1ConflictMerger implements StorageSyncHelper.ConflictMerger<SignalGroupV1Record> { @Override public @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords) { return Stream.of(remoteRecords) .filterNot(GroupV1ConflictMerger::isValidGroupId) .toList(); } }
GroupV1ConflictMerger implements StorageSyncHelper.ConflictMerger<SignalGroupV1Record> { @Override public @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords) { return Stream.of(remoteRecords) .filterNot(GroupV1ConflictMerger::isValidGroupId) .toList(); } GroupV1ConflictMerger(@NonNull Collection<SignalGroupV1Record> localOnly); }
GroupV1ConflictMerger implements StorageSyncHelper.ConflictMerger<SignalGroupV1Record> { @Override public @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords) { return Stream.of(remoteRecords) .filterNot(GroupV1ConflictMerger::isValidGroupId) .toList(); } GroupV1ConflictMerger(@NonNull Collection<SignalGroupV1Record> localOnly); @Override @NonNull Optional<SignalGroupV1Record> getMatching(@NonNull SignalGroupV1Record record); @Override @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords); @Override @NonNull SignalGroupV1Record merge(@NonNull SignalGroupV1Record remote, @NonNull SignalGroupV1Record local, @NonNull StorageSyncHelper.KeyGenerator keyGenerator); }
GroupV1ConflictMerger implements StorageSyncHelper.ConflictMerger<SignalGroupV1Record> { @Override public @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords) { return Stream.of(remoteRecords) .filterNot(GroupV1ConflictMerger::isValidGroupId) .toList(); } GroupV1ConflictMerger(@NonNull Collection<SignalGroupV1Record> localOnly); @Override @NonNull Optional<SignalGroupV1Record> getMatching(@NonNull SignalGroupV1Record record); @Override @NonNull Collection<SignalGroupV1Record> getInvalidEntries(@NonNull Collection<SignalGroupV1Record> remoteRecords); @Override @NonNull SignalGroupV1Record merge(@NonNull SignalGroupV1Record remote, @NonNull SignalGroupV1Record local, @NonNull StorageSyncHelper.KeyGenerator keyGenerator);  }