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