@Test public void describe_a_group_you_are_not_in() { DecryptedGroup group = newGroupBy(alice, 1) .build(); assertThat(describeNewGroup(group), is("Group updated.")); }
UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) { Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid); if (selfPending.isPresent()) { return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy)); } ByteString foundingMemberUuid = decryptedGroupChange.getEditor(); if (!foundingMemberUuid.isEmpty()) { if (selfUuidBytes.equals(foundingMemberUuid)) { return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group)); } else { return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator)); } } if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) { return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group)); } else { return updateDescription(context.getString(R.string.MessageRecord_group_updated)); } }
GroupsV2UpdateMessageProducer { UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) { Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid); if (selfPending.isPresent()) { return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy)); } ByteString foundingMemberUuid = decryptedGroupChange.getEditor(); if (!foundingMemberUuid.isEmpty()) { if (selfUuidBytes.equals(foundingMemberUuid)) { return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group)); } else { return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator)); } } if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) { return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group)); } else { return updateDescription(context.getString(R.string.MessageRecord_group_updated)); } } }
GroupsV2UpdateMessageProducer { UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) { Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid); if (selfPending.isPresent()) { return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy)); } ByteString foundingMemberUuid = decryptedGroupChange.getEditor(); if (!foundingMemberUuid.isEmpty()) { if (selfUuidBytes.equals(foundingMemberUuid)) { return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group)); } else { return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator)); } } if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) { return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group)); } else { return updateDescription(context.getString(R.string.MessageRecord_group_updated)); } } GroupsV2UpdateMessageProducer(@NonNull Context context,
                                @NonNull DescribeMemberStrategy descriptionStrategy,
                                @NonNull UUID selfUuid); }
GroupsV2UpdateMessageProducer { UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) { Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid); if (selfPending.isPresent()) { return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy)); } ByteString foundingMemberUuid = decryptedGroupChange.getEditor(); if (!foundingMemberUuid.isEmpty()) { if (selfUuidBytes.equals(foundingMemberUuid)) { return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group)); } else { return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator)); } } if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) { return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group)); } else { return updateDescription(context.getString(R.string.MessageRecord_group_updated)); } } GroupsV2UpdateMessageProducer(@NonNull Context context,
                                @NonNull DescribeMemberStrategy descriptionStrategy,
                                @NonNull UUID selfUuid);  }
GroupsV2UpdateMessageProducer { UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) { Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid); if (selfPending.isPresent()) { return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy)); } ByteString foundingMemberUuid = decryptedGroupChange.getEditor(); if (!foundingMemberUuid.isEmpty()) { if (selfUuidBytes.equals(foundingMemberUuid)) { return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group)); } else { return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator)); } } if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) { return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group)); } else { return updateDescription(context.getString(R.string.MessageRecord_group_updated)); } } GroupsV2UpdateMessageProducer(@NonNull Context context,
                                @NonNull DescribeMemberStrategy descriptionStrategy,
                                @NonNull UUID selfUuid);   }