@Test public void can_extract_uuids_for_all_deleted_pending_excluding_bad_entries() { UUID uuid1 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID(); DecryptedPendingMemberRemoval decryptedMember1 = DecryptedPendingMemberRemoval.newBuilder() .setUuid(UuidUtil.toByteString(uuid1)) .build(); DecryptedPendingMemberRemoval decryptedMember2 = DecryptedPendingMemberRemoval.newBuilder() .setUuid(UuidUtil.toByteString(uuid2)) .build(); DecryptedPendingMemberRemoval decryptedMember3 = DecryptedPendingMemberRemoval.newBuilder() .setUuid(ByteString.copyFrom(Util.getSecretBytes(17))) .build(); DecryptedGroupChange groupChange = DecryptedGroupChange.newBuilder() .addDeletePendingMembers(decryptedMember1) .addDeletePendingMembers(decryptedMember2) .addDeletePendingMembers(decryptedMember3) .build(); List<UUID> removedUuids = DecryptedGroupUtil.removedPendingMembersUuidList(groupChange); assertThat(removedUuids, is(asList(uuid1, uuid2))); }
public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) { List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList(); ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size()); for (DecryptedPendingMemberRemoval member : deletedPendingMembers) { UUID uuid = toUuid(member.getUuid()); if(!UuidUtil.UNKNOWN_UUID.equals(uuid)) { uuidList.add(uuid); } } return uuidList; }
DecryptedGroupUtil { public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) { List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList(); ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size()); for (DecryptedPendingMemberRemoval member : deletedPendingMembers) { UUID uuid = toUuid(member.getUuid()); if(!UuidUtil.UNKNOWN_UUID.equals(uuid)) { uuidList.add(uuid); } } return uuidList; } }
DecryptedGroupUtil { public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) { List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList(); ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size()); for (DecryptedPendingMemberRemoval member : deletedPendingMembers) { UUID uuid = toUuid(member.getUuid()); if(!UuidUtil.UNKNOWN_UUID.equals(uuid)) { uuidList.add(uuid); } } return uuidList; }  }
DecryptedGroupUtil { public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) { List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList(); ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size()); for (DecryptedPendingMemberRemoval member : deletedPendingMembers) { UUID uuid = toUuid(member.getUuid()); if(!UuidUtil.UNKNOWN_UUID.equals(uuid)) { uuidList.add(uuid); } } return uuidList; }  static ArrayList<UUID> toUuidList(Collection<DecryptedMember> membersList); static ArrayList<UUID> membersToUuidList(Collection<DecryptedMember> membersList); static Set<ByteString> membersToUuidByteStringSet(Collection<DecryptedMember> membersList); static ArrayList<UUID> pendingToUuidList(Collection<DecryptedPendingMember> membersList); static ArrayList<UUID> removedMembersUuidList(DecryptedGroupChange groupChange); static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange); static ArrayList<UUID> removedRequestingMembersUuidList(DecryptedGroupChange groupChange); static UUID toUuid(DecryptedMember member); static UUID toUuid(DecryptedPendingMember member); static Optional<UUID> editorUuid(DecryptedGroupChange change); static Optional<DecryptedMember> findMemberByUuid(Collection<DecryptedMember> members, UUID uuid); static Optional<DecryptedPendingMember> findPendingByUuid(Collection<DecryptedPendingMember> members, UUID uuid); static Optional<DecryptedRequestingMember> findRequestingByUuid(Collection<DecryptedRequestingMember> members, UUID uuid); static boolean isPendingOrRequesting(DecryptedGroup group, UUID uuid); static DecryptedGroup removeMember(DecryptedGroup group, UUID uuid, int revision); static DecryptedGroup apply(DecryptedGroup group, DecryptedGroupChange change); static DecryptedGroup applyWithoutRevisionCheck(DecryptedGroup group, DecryptedGroupChange change); static Optional<UUID> findInviter(List<DecryptedPendingMember> pendingMembersList, UUID uuid); static boolean changeIsEmpty(DecryptedGroupChange change); static boolean changeIsEmptyExceptForProfileKeyChanges(DecryptedGroupChange change); }
DecryptedGroupUtil { public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) { List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList(); ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size()); for (DecryptedPendingMemberRemoval member : deletedPendingMembers) { UUID uuid = toUuid(member.getUuid()); if(!UuidUtil.UNKNOWN_UUID.equals(uuid)) { uuidList.add(uuid); } } return uuidList; }  static ArrayList<UUID> toUuidList(Collection<DecryptedMember> membersList); static ArrayList<UUID> membersToUuidList(Collection<DecryptedMember> membersList); static Set<ByteString> membersToUuidByteStringSet(Collection<DecryptedMember> membersList); static ArrayList<UUID> pendingToUuidList(Collection<DecryptedPendingMember> membersList); static ArrayList<UUID> removedMembersUuidList(DecryptedGroupChange groupChange); static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange); static ArrayList<UUID> removedRequestingMembersUuidList(DecryptedGroupChange groupChange); static UUID toUuid(DecryptedMember member); static UUID toUuid(DecryptedPendingMember member); static Optional<UUID> editorUuid(DecryptedGroupChange change); static Optional<DecryptedMember> findMemberByUuid(Collection<DecryptedMember> members, UUID uuid); static Optional<DecryptedPendingMember> findPendingByUuid(Collection<DecryptedPendingMember> members, UUID uuid); static Optional<DecryptedRequestingMember> findRequestingByUuid(Collection<DecryptedRequestingMember> members, UUID uuid); static boolean isPendingOrRequesting(DecryptedGroup group, UUID uuid); static DecryptedGroup removeMember(DecryptedGroup group, UUID uuid, int revision); static DecryptedGroup apply(DecryptedGroup group, DecryptedGroupChange change); static DecryptedGroup applyWithoutRevisionCheck(DecryptedGroup group, DecryptedGroupChange change); static Optional<UUID> findInviter(List<DecryptedPendingMember> pendingMembersList, UUID uuid); static boolean changeIsEmpty(DecryptedGroupChange change); static boolean changeIsEmptyExceptForProfileKeyChanges(DecryptedGroupChange change);  }