From 79f792298075d7bb1c2dc03e19654545dfaec399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jc=20Mi=C3=B1arro?= Date: Tue, 8 Aug 2023 18:11:55 +0200 Subject: [PATCH] Use testFixtures to build random models --- .../api/stream-chat-android-client-test.api | 20 - .../chat/android/client/test/Mother.kt | 347 +----------------- .../client/test/utils/TestDataHelper.kt | 2 +- .../chat/android/client/ChatClientTest.kt | 4 +- .../chat/android/client/ConnectUserTest.kt | 2 +- .../android/client/DevicesApiCallsTests.kt | 2 +- .../getstream/chat/android/client/Mother.kt | 37 +- .../api/models/QueryChannelRequestTests.kt | 2 +- .../client/api/models/QuerySortByFieldTest.kt | 2 +- .../models/querysort/QuerySortByFieldTest.kt | 2 +- .../attachment/AttachmentUploaderTests.kt | 6 +- .../attachment/AttachmentsVerifierTests.kt | 2 +- .../android/client/call/CoroutineCallTest.kt | 4 +- .../android/client/call/DistinctCallTest.kt | 6 +- .../android/client/call/DoOnResultCallTest.kt | 4 +- .../android/client/call/DoOnStartCallTest.kt | 4 +- .../chat/android/client/call/MapCallTest.kt | 2 +- .../android/client/call/RetrofitCallTest.kt | 5 +- .../client/call/ReturnOnErrorCallTest.kt | 7 +- .../chat/android/client/call/ZipCallTest.kt | 4 +- .../client/chatclient/WhenFetchCurrentUser.kt | 2 +- .../clientstate/UserStateServiceTests.kt | 2 +- .../client/debugger/ChatClientDebuggerTest.kt | 4 +- .../client/helpers/AttachmentHelperTests.kt | 2 +- .../client/helpers/CallPostponeHelperTests.kt | 4 +- .../internal/PrepareMessageLogicImplTest.kt | 10 +- .../parser/FilterObjectTypeAdapterTest.kt | 8 +- .../android/client/socket/FakeChatSocket.kt | 2 +- .../client/socket/HealthMonitorTest.kt | 2 +- .../client/socket/SocketFactoryTest.kt | 4 +- .../ChatSocketStateServiceTest.kt | 55 +-- .../experimental/ws/StreamWebSocketTest.kt | 8 +- .../token/CacheableTokenProviderTest.kt | 4 +- .../client/user/CurrentUserFetcherTests.kt | 6 +- .../android/client/utils/TokenUtilsTest.kt | 2 +- .../utils/buffer/StartStopBufferTest.kt | 2 +- .../observable/ChatEventsObservableTest.kt | 4 +- .../MediaAttachmentPreviewHandlerTest.kt | 2 +- .../Mother.kt | 38 -- .../getstream/chat/android/offline/Mother.kt | 27 +- .../chat/android/offline/PaginationTest.kt | 2 +- .../offline/integration/BaseDomainTest2.kt | 2 +- .../BaseRepositoryFacadeIntegrationTest.kt | 2 +- .../listener/internal/CreateChannelTests.kt | 6 +- .../DeleteMessageListenerDatabaseTest.kt | 6 +- .../DeleteReactionListenerDatabaseTest.kt | 10 +- .../EditMessageListenerDatabaseTest.kt | 2 +- .../HideChannelListenerDatabaseTest.kt | 4 +- .../QueryMembersListenerDatabaseTest.kt | 6 +- .../SendMessageListenerDatabaseTest.kt | 4 +- .../SendReactionListenerDatabaseTest.kt | 8 +- .../ShuffleGiphyListenerDatabaseTest.kt | 4 +- .../ThreadQueryListenerDatabaseTest.kt | 6 +- .../repository/ChannelConfigRepositoryTest.kt | 12 +- .../repository/MessageRepositoryTests.kt | 6 +- .../repository/ReactionRepositoryTest.kt | 6 +- .../offline/repository/UserRepositoryTests.kt | 2 +- .../converter/FilterObjectConverterTest.kt | 8 +- .../internal/ChannelRepositoryImplTest.kt | 6 +- .../internal/DatabaseChannelRepositoryTest.kt | 8 +- .../RepositoryFacadeIntegrationTests.kt | 10 +- .../integration/MessageRepositoryTest.kt | 12 +- .../channel/AttachmentUrlValidatorTests.kt | 6 +- .../channel/controller/WhenHandleEvent.kt | 8 +- .../UploadAttachmentsIntegrationTests.kt | 6 +- .../attachment/WhenUploadAttachmentsTests.kt | 6 +- .../android/state/events/TypingEventsTest.kt | 2 +- .../state/facade/RepositoryFacadeTests.kt | 18 +- .../android/state/facade/WhenEnrichChannel.kt | 4 +- .../state/facade/WhenUpdateLastMessage.kt | 4 +- .../DeleteReactionErrorHandlerImplTest.kt | 4 +- .../android/state/internal/SyncManagerTest.kt | 10 +- .../state/internal/TypingEventPrunerTest.kt | 2 +- .../extensions/ChannelExtensionsTest.kt | 2 +- .../extensions/MemberExtensionsTest.kt | 4 +- .../extensions/ReactionExtensionsTest.kt | 2 +- .../DeleteMessageListenerStateTest.kt | 6 +- .../DeleteReactionListenerStateTest.kt | 8 +- .../internal/EditMessageListenerStateTest.kt | 2 +- .../internal/HideChannelListenerStateTest.kt | 4 +- .../internal/SendMessageListenerStateTest.kt | 4 +- .../internal/ShuffleGiphyListenerStateTest.kt | 4 +- .../internal/ThreadQueryListenerStateTest.kt | 6 +- .../channel/internal/ChannelStateLogicTest.kt | 20 +- .../internal/QueryChannelsStateLogicTest.kt | 6 +- .../DefaultChatEventHandlerTest.kt | 10 +- .../querychannels/QueryChannelsSortTest.kt | 2 +- .../SendReactionListenerStateTest.kt | 6 +- .../state/utils/CustomObjectFilteringTest.kt | 20 +- .../chat/android/state/utils/Mother.kt | 33 -- .../io/getstream/chat/android/test/Mother.kt | 85 ----- .../chat/android/ui/common/Mother.kt | 210 ----------- .../list/MessageListControllerTests.kt | 43 +-- .../ui/common/utils/StringUtilsTest.kt | 2 +- .../io/getstream/chat/android/ui/Mother.kt | 224 ----------- .../chat/android/ui/utils/ChannelKtTest.kt | 12 +- .../android/ui/utils/MessageEllipsizeTest.kt | 2 +- 97 files changed, 293 insertions(+), 1278 deletions(-) delete mode 100644 stream-chat-android-core/src/test/java/io.getstream.chat.android.client/Mother.kt delete mode 100644 stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/Mother.kt delete mode 100644 stream-chat-android-test/src/main/java/io/getstream/chat/android/test/Mother.kt delete mode 100644 stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/Mother.kt delete mode 100644 stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/Mother.kt diff --git a/stream-chat-android-client-test/api/stream-chat-android-client-test.api b/stream-chat-android-client-test/api/stream-chat-android-client-test.api index 4f5a031c725..375fc667a58 100644 --- a/stream-chat-android-client-test/api/stream-chat-android-client-test.api +++ b/stream-chat-android-client-test/api/stream-chat-android-client-test.api @@ -6,34 +6,20 @@ public final class io/getstream/chat/android/client/test/BuildConfig { } public final class io/getstream/chat/android/client/test/MotherKt { - public static final fun randomAttachment (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/io/File;Lio/getstream/chat/android/models/Attachment$UploadState;Ljava/util/Map;)Lio/getstream/chat/android/models/Attachment; - public static synthetic fun randomAttachment$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/io/File;Lio/getstream/chat/android/models/Attachment$UploadState;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/models/Attachment; - public static final fun randomChannel (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/SyncStatus;ILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lio/getstream/chat/android/models/Config;Lio/getstream/chat/android/models/User;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Boolean;Ljava/util/Date;Ljava/util/Map;)Lio/getstream/chat/android/models/Channel; - public static synthetic fun randomChannel$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/SyncStatus;ILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lio/getstream/chat/android/models/Config;Lio/getstream/chat/android/models/User;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Boolean;Ljava/util/Date;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/models/Channel; - public static final fun randomChannelConfig (Ljava/lang/String;Lio/getstream/chat/android/models/Config;)Lio/getstream/chat/android/models/ChannelConfig; - public static synthetic fun randomChannelConfig$default (Ljava/lang/String;Lio/getstream/chat/android/models/Config;ILjava/lang/Object;)Lio/getstream/chat/android/models/ChannelConfig; public static final fun randomChannelDeletedEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Channel;)Lio/getstream/chat/android/client/events/ChannelDeletedEvent; public static synthetic fun randomChannelDeletedEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Channel;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/ChannelDeletedEvent; - public static final fun randomChannelInfo (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)Lio/getstream/chat/android/models/ChannelInfo; - public static synthetic fun randomChannelInfo$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ILjava/lang/Object;)Lio/getstream/chat/android/models/ChannelInfo; public static final fun randomChannelUpdatedByUserEvent (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;)Lio/getstream/chat/android/client/events/ChannelUpdatedByUserEvent; public static synthetic fun randomChannelUpdatedByUserEvent$default (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/ChannelUpdatedByUserEvent; public static final fun randomChannelUpdatedEvent (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Channel;)Lio/getstream/chat/android/client/events/ChannelUpdatedEvent; public static synthetic fun randomChannelUpdatedEvent$default (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Channel;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/ChannelUpdatedEvent; public static final fun randomChannelVisibleEvent (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/User;)Lio/getstream/chat/android/client/events/ChannelVisibleEvent; public static synthetic fun randomChannelVisibleEvent$default (Ljava/util/Date;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/User;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/ChannelVisibleEvent; - public static final fun randomConfig (Ljava/util/Date;Ljava/util/Date;Ljava/lang/String;ZZZZZZZZZZZLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)Lio/getstream/chat/android/models/Config; - public static synthetic fun randomConfig$default (Ljava/util/Date;Ljava/util/Date;Ljava/lang/String;ZZZZZZZZZZZLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/chat/android/models/Config; - public static final fun randomMember (Lio/getstream/chat/android/models/User;Ljava/util/Date;Ljava/util/Date;Ljava/lang/Boolean;Ljava/util/Date;Ljava/util/Date;Z)Lio/getstream/chat/android/models/Member; - public static synthetic fun randomMember$default (Lio/getstream/chat/android/models/User;Ljava/util/Date;Ljava/util/Date;Ljava/lang/Boolean;Ljava/util/Date;Ljava/util/Date;ZILjava/lang/Object;)Lio/getstream/chat/android/models/Member; public static final fun randomMemberAddedEvent (Ljava/lang/String;)Lio/getstream/chat/android/client/events/MemberAddedEvent; public static final fun randomMemberAddedEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Member;)Lio/getstream/chat/android/client/events/MemberAddedEvent; public static synthetic fun randomMemberAddedEvent$default (Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/MemberAddedEvent; public static synthetic fun randomMemberAddedEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Member;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/MemberAddedEvent; public static final fun randomMemberRemovedEvent (Ljava/lang/String;Lio/getstream/chat/android/models/Member;)Lio/getstream/chat/android/client/events/MemberRemovedEvent; public static synthetic fun randomMemberRemovedEvent$default (Ljava/lang/String;Lio/getstream/chat/android/models/Member;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/MemberRemovedEvent; - public static final fun randomMessage (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILjava/util/Map;Ljava/util/Map;Lio/getstream/chat/android/models/SyncStatus;Ljava/lang/String;Ljava/util/List;Ljava/util/List;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/util/Map;ZLio/getstream/chat/android/models/Message;ZZLio/getstream/chat/android/models/ChannelInfo;Ljava/lang/String;ZLjava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/util/List;)Lio/getstream/chat/android/models/Message; - public static synthetic fun randomMessage$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILjava/util/Map;Ljava/util/Map;Lio/getstream/chat/android/models/SyncStatus;Ljava/lang/String;Ljava/util/List;Ljava/util/List;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/util/Map;ZLio/getstream/chat/android/models/Message;ZZLio/getstream/chat/android/models/ChannelInfo;Ljava/lang/String;ZLjava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/util/List;IILjava/lang/Object;)Lio/getstream/chat/android/models/Message; public static final fun randomMessageReadEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/chat/android/client/events/MessageReadEvent; public static synthetic fun randomMessageReadEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/MessageReadEvent; public static final fun randomMessageUpdateEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;)Lio/getstream/chat/android/client/events/MessageUpdatedEvent; @@ -56,18 +42,12 @@ public final class io/getstream/chat/android/client/test/MotherKt { public static synthetic fun randomNotificationRemovedFromChannelEvent$default (Ljava/lang/String;Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/Member;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/NotificationRemovedFromChannelEvent; public static final fun randomQueryChannelsSpec (Lio/getstream/chat/android/models/FilterObject;Lio/getstream/chat/android/models/querysort/QuerySorter;Ljava/util/Set;)Lio/getstream/chat/android/client/query/QueryChannelsSpec; public static synthetic fun randomQueryChannelsSpec$default (Lio/getstream/chat/android/models/FilterObject;Lio/getstream/chat/android/models/querysort/QuerySorter;Ljava/util/Set;ILjava/lang/Object;)Lio/getstream/chat/android/client/query/QueryChannelsSpec; - public static final fun randomReaction (Ljava/lang/String;Ljava/lang/String;ILio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/SyncStatus;Ljava/util/Map;Z)Lio/getstream/chat/android/models/Reaction; - public static synthetic fun randomReaction$default (Ljava/lang/String;Ljava/lang/String;ILio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;Lio/getstream/chat/android/models/SyncStatus;Ljava/util/Map;ZILjava/lang/Object;)Lio/getstream/chat/android/models/Reaction; public static final fun randomReactionNewEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Reaction;)Lio/getstream/chat/android/client/events/ReactionNewEvent; public static synthetic fun randomReactionNewEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/Reaction;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/ReactionNewEvent; - public static final fun randomSyncStatus (Ljava/util/List;)Lio/getstream/chat/android/models/SyncStatus; - public static synthetic fun randomSyncStatus$default (Ljava/util/List;ILjava/lang/Object;)Lio/getstream/chat/android/models/SyncStatus; public static final fun randomTypingStartEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/chat/android/client/events/TypingStartEvent; public static synthetic fun randomTypingStartEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/TypingStartEvent; public static final fun randomTypingStopEvent (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/chat/android/client/events/TypingStopEvent; public static synthetic fun randomTypingStopEvent$default (Ljava/lang/String;Ljava/util/Date;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/TypingStopEvent; - public static final fun randomUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;ZLjava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;IILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/Map;)Lio/getstream/chat/android/models/User; - public static synthetic fun randomUser$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;ZLjava/util/Date;Ljava/util/Date;Ljava/util/Date;Ljava/util/Date;IILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/models/User; public static final fun randomUserStartWatchingEvent (Ljava/util/Date;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/User;)Lio/getstream/chat/android/client/events/UserStartWatchingEvent; public static synthetic fun randomUserStartWatchingEvent$default (Ljava/util/Date;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/User;ILjava/lang/Object;)Lio/getstream/chat/android/client/events/UserStartWatchingEvent; } diff --git a/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/Mother.kt b/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/Mother.kt index 7a9bffc4cb7..d6dd5fb18bd 100644 --- a/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/Mother.kt +++ b/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/Mother.kt @@ -36,36 +36,25 @@ import io.getstream.chat.android.client.events.TypingStopEvent import io.getstream.chat.android.client.events.UserStartWatchingEvent import io.getstream.chat.android.client.parser2.adapters.internal.StreamDateFormatter import io.getstream.chat.android.client.query.QueryChannelsSpec -import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Channel -import io.getstream.chat.android.models.ChannelConfig -import io.getstream.chat.android.models.ChannelInfo -import io.getstream.chat.android.models.ChannelMute -import io.getstream.chat.android.models.ChannelUserRead -import io.getstream.chat.android.models.Command -import io.getstream.chat.android.models.Config -import io.getstream.chat.android.models.Device import io.getstream.chat.android.models.EventType import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.Member import io.getstream.chat.android.models.Message -import io.getstream.chat.android.models.Mute import io.getstream.chat.android.models.NeutralFilterObject import io.getstream.chat.android.models.Reaction -import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.User import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySorter -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomExtraData -import io.getstream.chat.android.test.randomFile -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomIntBetween -import io.getstream.chat.android.test.randomString -import java.io.File +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import java.util.Date private val streamFormatter = StreamDateFormatter() @@ -345,277 +334,6 @@ public fun randomMessageUpdateEvent( message = message, ) -public fun randomUser( - id: String = randomString(), - name: String = randomString(), - image: String = randomString(), - role: String = randomString(), - invisible: Boolean = randomBoolean(), - banned: Boolean = randomBoolean(), - devices: List = mutableListOf(), - online: Boolean = randomBoolean(), - createdAt: Date? = null, - deactivatedAt: Date? = null, - updatedAt: Date? = null, - lastActive: Date? = null, - totalUnreadCount: Int = positiveRandomInt(), - unreadChannels: Int = positiveRandomInt(), - mutes: List = mutableListOf(), - teams: List = listOf(), - channelMutes: List = emptyList(), - extraData: MutableMap = mutableMapOf(), -): User = User( - id = id, - role = role, - name = name, - image = image, - invisible = invisible, - banned = banned, - devices = devices, - online = online, - createdAt = createdAt, - deactivatedAt = deactivatedAt, - updatedAt = updatedAt, - lastActive = lastActive, - totalUnreadCount = totalUnreadCount, - unreadChannels = unreadChannels, - mutes = mutes, - teams = teams, - channelMutes = channelMutes, - extraData = extraData, -) - -public fun randomMessage( - id: String = randomString(), - cid: String = randomCID(), - text: String = randomString(), - html: String = randomString(), - parentId: String? = randomString(), - command: String? = randomString(), - attachments: MutableList = mutableListOf(), - mentionedUsers: MutableList = mutableListOf(), - replyCount: Int = randomInt(), - reactionCounts: MutableMap = mutableMapOf(), - reactionScores: MutableMap = mutableMapOf(), - syncStatus: SyncStatus = randomSyncStatus(), - type: String = randomString(), - latestReactions: MutableList = mutableListOf(), - ownReactions: MutableList = mutableListOf(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - updatedLocallyAt: Date? = randomDate(), - createdLocallyAt: Date? = randomDate(), - user: User = randomUser(), - extraData: MutableMap = mutableMapOf(), - silent: Boolean = randomBoolean(), - replyTo: Message? = null, - showInChannel: Boolean = randomBoolean(), - shadowed: Boolean = false, - channelInfo: ChannelInfo? = randomChannelInfo(), - replyMessageId: String? = randomString(), - pinned: Boolean = randomBoolean(), - pinnedAt: Date? = randomDate(), - pinExpires: Date? = randomDate(), - pinnedBy: User? = randomUser(), - threadParticipants: List = emptyList(), -): Message = Message( - id = id, - cid = cid, - text = text, - html = html, - parentId = parentId, - command = command, - attachments = attachments, - mentionedUsersIds = mentionedUsers.map(User::id).toMutableList(), - mentionedUsers = mentionedUsers, - replyCount = replyCount, - reactionCounts = reactionCounts, - reactionScores = reactionScores, - syncStatus = syncStatus, - type = type, - latestReactions = latestReactions, - ownReactions = ownReactions, - createdAt = createdAt, - updatedAt = updatedAt, - deletedAt = deletedAt, - updatedLocallyAt = updatedLocallyAt, - createdLocallyAt = createdLocallyAt, - user = user, - extraData = extraData, - silent = silent, - replyTo = replyTo, - showInChannel = showInChannel, - shadowed = shadowed, - channelInfo = channelInfo, - replyMessageId = replyMessageId, - pinned = pinned, - pinnedAt = pinnedAt, - pinExpires = pinExpires, - pinnedBy = pinnedBy, - threadParticipants = threadParticipants, -) - -public fun randomChannelInfo( - cid: String? = randomString(), - id: String? = randomString(), - type: String = randomString(), - memberCount: Int = randomInt(), - name: String? = randomString(), -): ChannelInfo = ChannelInfo( - cid = cid, - id = id, - type = type, - memberCount = memberCount, - name = name, -) - -public fun randomChannel( - id: String = randomString(), - name: String = randomString(), - type: String = randomString(), - watcherCount: Int = randomInt(), - frozen: Boolean = randomBoolean(), - lastMessageAt: Date? = randomDate(), - createdAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - syncStatus: SyncStatus = randomSyncStatus(), - memberCount: Int = randomInt(), - messages: List = mutableListOf(), - members: List = mutableListOf(), - watchers: List = mutableListOf(), - read: List = mutableListOf(), - config: Config = Config(), - createdBy: User = randomUser(), - unreadCount: Int? = randomInt(), - team: String = randomString(), - hidden: Boolean? = randomBoolean(), - hiddenMessagesBefore: Date? = randomDate(), - extraData: Map = emptyMap(), -): Channel = Channel( - id = id, - name = name, - type = type, - watcherCount = watcherCount, - frozen = frozen, - lastMessageAt = lastMessageAt, - createdAt = createdAt, - deletedAt = deletedAt, - updatedAt = updatedAt, - syncStatus = syncStatus, - memberCount = memberCount, - messages = messages, - members = members, - watchers = watchers, - read = read, - config = config, - createdBy = createdBy, - unreadCount = unreadCount, - team = team, - hidden = hidden, - hiddenMessagesBefore = hiddenMessagesBefore, - extraData = extraData, -) - -public fun randomMember( - user: User = randomUser(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - isInvited: Boolean? = randomBoolean(), - inviteAcceptedAt: Date? = randomDate(), - inviteRejectedAt: Date? = randomDate(), - shadowBanned: Boolean = randomBoolean(), -): Member = Member( - user = user, - createdAt = createdAt, - updatedAt = updatedAt, - isInvited = isInvited, - inviteAcceptedAt = inviteAcceptedAt, - inviteRejectedAt = inviteRejectedAt, - shadowBanned = shadowBanned, -) - -public fun randomReaction( - messageId: String = randomString(), - type: String = randomString(), - score: Int = randomInt(), - user: User? = randomUser(), - userId: String = randomString(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - syncStatus: SyncStatus = randomSyncStatus(), - extraData: MutableMap = mutableMapOf(), - enforceUnique: Boolean = randomBoolean(), -): Reaction = Reaction( - messageId = messageId, - type = type, - score = score, - user = user, - userId = userId, - createdAt = createdAt, - updatedAt = updatedAt, - deletedAt = deletedAt, - syncStatus = syncStatus, - extraData = extraData, - enforceUnique = enforceUnique, -) - -public fun randomSyncStatus(exclude: List = emptyList()): SyncStatus = - (SyncStatus.values().asList() - exclude - SyncStatus.AWAITING_ATTACHMENTS).random() - -public fun randomAttachment( - authorName: String? = randomString(), - authorLink: String? = randomString(), - titleLink: String? = randomString(), - thumbUrl: String? = randomString(), - imageUrl: String? = randomString(), - assetUrl: String? = randomString(), - ogUrl: String? = randomString(), - mimeType: String? = randomString(), - fileSize: Int = randomIntBetween( - min = 1 * 1024 * 1024, - max = 100 * 1024 * 1024, - ), - title: String? = randomString(), - text: String? = randomString(), - type: String? = randomString(), - image: String? = randomString(), - url: String? = randomString(), - name: String? = randomString(), - fallback: String? = randomString(), - originalHeight: Int? = randomInt(), - originalWidth: Int? = randomInt(), - upload: File? = randomFile(), - uploadState: Attachment.UploadState? = Attachment.UploadState.Success, - extraData: Map = randomExtraData(), -): Attachment { - return Attachment( - authorName = authorName, - authorLink = authorLink, - titleLink = titleLink, - thumbUrl = thumbUrl, - imageUrl = imageUrl, - assetUrl = assetUrl, - ogUrl = ogUrl, - mimeType = mimeType, - fileSize = fileSize, - title = title, - text = text, - type = type, - image = image, - url = url, - name = name, - fallback = fallback, - originalHeight = originalHeight, - originalWidth = originalWidth, - upload = upload, - uploadState = uploadState, - extraData = extraData, - ) -} - public fun randomChannelUpdatedEvent( createdAt: Date = randomDate(), cid: String = randomString(), @@ -684,53 +402,6 @@ public fun randomNewMessageEvent( ) } -public fun randomConfig( - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - name: String = randomString(), - typingEventsEnabled: Boolean = randomBoolean(), - readEventsEnabled: Boolean = randomBoolean(), - connectEventsEnabled: Boolean = randomBoolean(), - searchEnabled: Boolean = randomBoolean(), - isReactionsEnabled: Boolean = randomBoolean(), - isRepliesEnabled: Boolean = randomBoolean(), - muteEnabled: Boolean = randomBoolean(), - uploadsEnabled: Boolean = randomBoolean(), - urlEnrichmentEnabled: Boolean = randomBoolean(), - customEventsEnabled: Boolean = randomBoolean(), - pushNotificationsEnabled: Boolean = randomBoolean(), - messageRetention: String = randomString(), - maxMessageLength: Int = randomInt(), - automod: String = randomString(), - automodBehavior: String = randomString(), - blocklistBehavior: String = randomString(), - commands: List = emptyList(), -): Config = Config( - createdAt = createdAt, - updatedAt = updatedAt, - name = name, - typingEventsEnabled = typingEventsEnabled, - readEventsEnabled = readEventsEnabled, - connectEventsEnabled = connectEventsEnabled, - searchEnabled = searchEnabled, - isReactionsEnabled = isReactionsEnabled, - isThreadEnabled = isRepliesEnabled, - muteEnabled = muteEnabled, - uploadsEnabled = uploadsEnabled, - urlEnrichmentEnabled = urlEnrichmentEnabled, - customEventsEnabled = customEventsEnabled, - pushNotificationsEnabled = pushNotificationsEnabled, - messageRetention = messageRetention, - maxMessageLength = maxMessageLength, - automod = automod, - automodBehavior = automodBehavior, - blocklistBehavior = blocklistBehavior, - commands = commands, -) - -public fun randomChannelConfig(type: String = randomString(), config: Config = randomConfig()): ChannelConfig = - ChannelConfig(type = type, config = config) - public fun randomQueryChannelsSpec( filter: FilterObject = NeutralFilterObject, sort: QuerySorter = QuerySortByField(), diff --git a/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/utils/TestDataHelper.kt b/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/utils/TestDataHelper.kt index 98809ca1ce9..d75f8b0798a 100644 --- a/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/utils/TestDataHelper.kt +++ b/stream-chat-android-client-test/src/main/java/io/getstream/chat/android/client/test/utils/TestDataHelper.kt @@ -57,7 +57,7 @@ import io.getstream.chat.android.models.Mute import io.getstream.chat.android.models.Reaction import io.getstream.chat.android.models.User import io.getstream.chat.android.models.querysort.QuerySortByField -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import io.getstream.result.Result import java.util.Calendar import java.util.Date diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ChatClientTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ChatClientTest.kt index 895384650a5..6fcc8bbaaeb 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ChatClientTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ChatClientTest.kt @@ -32,13 +32,13 @@ import io.getstream.chat.android.client.plugin.factory.PluginFactory import io.getstream.chat.android.client.scope.ClientTestScope import io.getstream.chat.android.client.scope.UserTestScope import io.getstream.chat.android.client.socket.FakeChatSocket -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.client.token.FakeTokenManager import io.getstream.chat.android.client.utils.TokenUtils import io.getstream.chat.android.client.utils.retry.NoRetryPolicy +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCall import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ConnectUserTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ConnectUserTest.kt index edff073ba47..a9e5affb76e 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ConnectUserTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/ConnectUserTest.kt @@ -35,9 +35,9 @@ import io.getstream.chat.android.models.EventType import io.getstream.chat.android.models.GuestUser import io.getstream.chat.android.models.InitializationState import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.chat.android.test.asCall -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/DevicesApiCallsTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/DevicesApiCallsTests.kt index d8a177ee0ab..15c49da0b4e 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/DevicesApiCallsTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/DevicesApiCallsTests.kt @@ -16,12 +16,12 @@ package io.getstream.chat.android.client -import io.getstream.chat.android.client.Mother.randomDevice import io.getstream.chat.android.client.utils.RetroError import io.getstream.chat.android.client.utils.RetroSuccess import io.getstream.chat.android.client.utils.verifyError import io.getstream.chat.android.client.utils.verifySuccess import io.getstream.chat.android.models.Device +import io.getstream.chat.android.randomDevice import io.getstream.chat.android.test.TestCoroutineExtension import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt index 21d7a3f34af..e16d1e9fd2d 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt @@ -26,38 +26,21 @@ import io.getstream.chat.android.client.parser2.adapters.internal.StreamDateForm import io.getstream.chat.android.client.setup.state.internal.MutableClientState import io.getstream.chat.android.client.socket.ChatSocketStateService import io.getstream.chat.android.client.socket.SocketFactory -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.ConnectionState -import io.getstream.chat.android.models.Device import io.getstream.chat.android.models.InitializationState -import io.getstream.chat.android.models.PushProvider import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomInt -import io.getstream.result.Error +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import java.util.Date -import java.util.UUID internal object Mother { private val streamDateFormatter = StreamDateFormatter() - fun randomString(): String = UUID.randomUUID().toString() - - fun randomDevice( - token: String = randomString(), - pushProvider: PushProvider = PushProvider.values().random(), - providerName: String? = randomString().takeIf { randomBoolean() }, - ): Device = - Device( - token = token, - pushProvider = pushProvider, - providerName = providerName, - ) - fun randomUserPresenceChangedEvent( type: String = randomString(), createdAt: Date = randomDate(), @@ -117,16 +100,4 @@ internal object Mother { ): ConnectedEvent { return ConnectedEvent(type, createdAt, streamDateFormatter.format(createdAt), me, connectionId) } - - fun randomChatNetworkError( - serverErrorCode: Int = randomInt(), - description: String = randomString(), - statusCode: Int = randomInt(), - cause: Throwable? = null, - ): Error.NetworkError = Error.NetworkError( - message = description, - serverErrorCode = serverErrorCode, - statusCode = statusCode, - cause = cause, - ) } diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QueryChannelRequestTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QueryChannelRequestTests.kt index ec226072087..7d91c049e36 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QueryChannelRequestTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QueryChannelRequestTests.kt @@ -16,7 +16,7 @@ package io.getstream.chat.android.client.api.models -import io.getstream.chat.android.test.randomInt +import io.getstream.chat.android.randomInt import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QuerySortByFieldTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QuerySortByFieldTest.kt index 161fa42aa66..3a50e119c96 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QuerySortByFieldTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/QuerySortByFieldTest.kt @@ -21,7 +21,7 @@ import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySortByField.Companion.ascByName import io.getstream.chat.android.models.querysort.QuerySorter -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/querysort/QuerySortByFieldTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/querysort/QuerySortByFieldTest.kt index 04afbfe0931..1135183ddcc 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/querysort/QuerySortByFieldTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api/models/querysort/QuerySortByFieldTest.kt @@ -21,7 +21,7 @@ import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.querysort.ComparableFieldProvider import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySortByField.Companion.ascByName -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentUploaderTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentUploaderTests.kt index e7ab2a3dcc0..d1e6fa45434 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentUploaderTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentUploaderTests.kt @@ -23,10 +23,10 @@ import io.getstream.chat.android.client.extensions.EXTRA_UPLOAD_ID import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.UploadedFile import io.getstream.chat.android.models.UploadedImage +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomFile +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCall -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomFile -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentsVerifierTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentsVerifierTests.kt index 8415e05f54d..1c8d230223c 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentsVerifierTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/attachment/AttachmentsVerifierTests.kt @@ -16,8 +16,8 @@ package io.getstream.chat.android.client.attachment -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.Attachment +import io.getstream.chat.android.randomMessage import io.getstream.chat.android.test.TestLoggingHelper import io.getstream.result.Result import org.amshove.kluent.`should be equal to` diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/CoroutineCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/CoroutineCallTest.kt index f59f2ecc089..2a531e8d274 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/CoroutineCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/CoroutineCallTest.kt @@ -17,7 +17,7 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedTask -import io.getstream.chat.android.client.Mother +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.result.Result import io.getstream.result.call.Call @@ -45,7 +45,7 @@ internal class CoroutineCallTest { val testCoroutines = TestCoroutineExtension() } - val resultValue = Mother.randomString() + val resultValue = randomString() val validResult: Result = Result.Success(resultValue) @Test diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DistinctCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DistinctCallTest.kt index 5a8bb16e411..7d7dac3c942 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DistinctCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DistinctCallTest.kt @@ -17,9 +17,9 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall -import io.getstream.chat.android.client.Mother +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.positiveRandomInt import io.getstream.result.Result import io.getstream.result.call.Call import io.getstream.result.call.DistinctCall @@ -46,7 +46,7 @@ internal class DistinctCallTest { val testCoroutines = TestCoroutineExtension() } - private val resultValue = Mother.randomString() + private val resultValue = randomString() private val validResult: Result = Result.Success(resultValue) @Test diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnResultCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnResultCallTest.kt index 9ee57ca517f..18ae4299d38 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnResultCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnResultCallTest.kt @@ -17,7 +17,7 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall -import io.getstream.chat.android.client.Mother +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.result.Result import io.getstream.result.call.Call @@ -43,7 +43,7 @@ internal class DoOnResultCallTest { val testCoroutines = TestCoroutineExtension() } - private val resultValue = Mother.randomString() + private val resultValue = randomString() private val validResult: Result = Result.Success(resultValue) private val consumer = SpyConsumer() diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnStartCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnStartCallTest.kt index c3a5b8fe2ff..51ab032b7ba 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnStartCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/DoOnStartCallTest.kt @@ -17,7 +17,7 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall -import io.getstream.chat.android.client.Mother +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.result.Result import io.getstream.result.call.Call @@ -42,7 +42,7 @@ internal class DoOnStartCallTest { val testCoroutines = TestCoroutineExtension() } - private val resultValue = Mother.randomString() + private val resultValue = randomString() private val validResult: Result = Result.Success(resultValue) private val sideEffect = SpySideEffect() diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/MapCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/MapCallTest.kt index 26ee1021055..2b1093fc705 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/MapCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/MapCallTest.kt @@ -17,8 +17,8 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall +import io.getstream.chat.android.positiveRandomInt import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.positiveRandomInt import io.getstream.result.Result import io.getstream.result.call.Call import io.getstream.result.call.map diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/RetrofitCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/RetrofitCallTest.kt index 4eb97ad8c72..12252a7516d 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/RetrofitCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/RetrofitCallTest.kt @@ -17,10 +17,9 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedRetrofit2Call -import io.getstream.chat.android.client.Mother import io.getstream.chat.android.client.parser.ChatParser +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import io.getstream.result.call.Call @@ -47,7 +46,7 @@ internal class RetrofitCallTest { val testCoroutines = TestCoroutineExtension() } - val resultValue = Mother.randomString() + val resultValue = randomString() val validResult: Result = Result.Success(resultValue) val parser: ChatParser = mock() diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ReturnOnErrorCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ReturnOnErrorCallTest.kt index 2263b04550f..b23f7fd9a95 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ReturnOnErrorCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ReturnOnErrorCallTest.kt @@ -17,9 +17,8 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall -import io.getstream.chat.android.client.Mother +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import io.getstream.result.call.Call @@ -45,8 +44,8 @@ internal class ReturnOnErrorCallTest { val testCoroutines = TestCoroutineExtension() } - private val resultValue = Mother.randomString() - private val errorResultValue = Mother.randomString() + private val resultValue = randomString() + private val errorResultValue = randomString() private val validResult: Result = Result.Success(resultValue) private val error: Error = Error.GenericError(message = randomString()) private val errorResult: Result = Result.Failure(error) diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ZipCallTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ZipCallTest.kt index 02ef11a2875..6985240c2dc 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ZipCallTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/call/ZipCallTest.kt @@ -17,9 +17,9 @@ package io.getstream.chat.android.client.call import io.getstream.chat.android.client.BlockedCall +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import io.getstream.result.call.Call diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/chatclient/WhenFetchCurrentUser.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/chatclient/WhenFetchCurrentUser.kt index fcbefcab2e1..9b88d095e6e 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/chatclient/WhenFetchCurrentUser.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/chatclient/WhenFetchCurrentUser.kt @@ -21,8 +21,8 @@ import io.getstream.chat.android.client.clientstate.UserState import io.getstream.chat.android.client.plugin.Plugin import io.getstream.chat.android.client.plugin.listeners.FetchCurrentUserListener import io.getstream.chat.android.client.socket.ChatSocket -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomUser import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/clientstate/UserStateServiceTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/clientstate/UserStateServiceTests.kt index a5c2a2b6a87..1060e6c9125 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/clientstate/UserStateServiceTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/clientstate/UserStateServiceTests.kt @@ -16,8 +16,8 @@ package io.getstream.chat.android.client.clientstate -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomUser import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeInstanceOf diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/debugger/ChatClientDebuggerTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/debugger/ChatClientDebuggerTest.kt index 1b366a3e946..2cd381ecdcd 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/debugger/ChatClientDebuggerTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/debugger/ChatClientDebuggerTest.kt @@ -31,14 +31,14 @@ import io.getstream.chat.android.client.plugin.factory.PluginFactory import io.getstream.chat.android.client.scope.ClientTestScope import io.getstream.chat.android.client.scope.UserTestScope import io.getstream.chat.android.client.socket.FakeChatSocket -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.client.token.FakeTokenManager import io.getstream.chat.android.client.utils.TokenUtils import io.getstream.chat.android.client.utils.retry.NoRetryPolicy import io.getstream.chat.android.models.Message +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.chat.android.test.asCall -import io.getstream.chat.android.test.randomString import io.getstream.result.Result import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/AttachmentHelperTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/AttachmentHelperTests.kt index 2cf3b3a3a65..1a7cace1f78 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/AttachmentHelperTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/AttachmentHelperTests.kt @@ -16,9 +16,9 @@ package io.getstream.chat.android.client.helpers -import io.getstream.chat.android.client.test.randomAttachment import io.getstream.chat.android.client.utils.TimeProvider import io.getstream.chat.android.models.Attachment +import io.getstream.chat.android.randomAttachment import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/CallPostponeHelperTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/CallPostponeHelperTests.kt index fb4a7e385e4..a9b432946ad 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/CallPostponeHelperTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/helpers/CallPostponeHelperTests.kt @@ -18,11 +18,11 @@ package io.getstream.chat.android.client.helpers import io.getstream.chat.android.client.scope.UserScope import io.getstream.chat.android.client.scope.UserTestScope -import io.getstream.chat.android.client.test.randomChannel import io.getstream.chat.android.models.Channel +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomChannel import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.chat.android.test.asCall -import io.getstream.chat.android.test.positiveRandomInt import io.getstream.result.Result import io.getstream.result.call.Call import kotlinx.coroutines.delay diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/interceptor/message/internal/PrepareMessageLogicImplTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/interceptor/message/internal/PrepareMessageLogicImplTest.kt index 87293114668..5613a6c2b7e 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/interceptor/message/internal/PrepareMessageLogicImplTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/interceptor/message/internal/PrepareMessageLogicImplTest.kt @@ -20,13 +20,13 @@ import io.getstream.chat.android.client.channel.ChannelMessagesUpdateLogic import io.getstream.chat.android.client.channel.state.ChannelStateLogicProvider import io.getstream.chat.android.client.extensions.uploadId import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomAttachment -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.test.randomFile -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomAttachment +import io.getstream.chat.android.randomFile +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import org.amshove.kluent.`should be equal to` import org.amshove.kluent.`should not be equal to` import org.junit.jupiter.api.Test diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/FilterObjectTypeAdapterTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/FilterObjectTypeAdapterTest.kt index 7290b1fc9a5..2efbf302316 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/FilterObjectTypeAdapterTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser/FilterObjectTypeAdapterTest.kt @@ -20,10 +20,10 @@ import io.getstream.chat.android.client.parser2.MoshiChatParser import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.Filters import io.getstream.chat.android.models.NeutralFilterObject -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomString import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/FakeChatSocket.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/FakeChatSocket.kt index 03c08437c53..c00d80cffea 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/FakeChatSocket.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/FakeChatSocket.kt @@ -27,7 +27,7 @@ import io.getstream.chat.android.client.token.FakeTokenManager import io.getstream.chat.android.client.token.TokenManager import io.getstream.chat.android.models.EventType import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import io.getstream.result.Result import okhttp3.WebSocketListener import org.mockito.kotlin.any diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/HealthMonitorTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/HealthMonitorTest.kt index 3f22df6e8ad..666663c93f8 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/HealthMonitorTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/HealthMonitorTest.kt @@ -18,8 +18,8 @@ package io.getstream.chat.android.client.socket import io.getstream.chat.android.client.scope.UserTestScope import io.getstream.chat.android.client.utils.TimeProvider +import io.getstream.chat.android.positiveRandomInt import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.positiveRandomInt import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.currentTime diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/SocketFactoryTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/SocketFactoryTest.kt index 6f09403126c..31fd60a7ed2 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/SocketFactoryTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/SocketFactoryTest.kt @@ -19,10 +19,10 @@ package io.getstream.chat.android.client.socket import io.getstream.chat.android.client.ChatClient import io.getstream.chat.android.client.parser.ChatParser import io.getstream.chat.android.client.parser2.MoshiChatParser -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.client.token.FakeTokenManager import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import okhttp3.OkHttpClient import okhttp3.WebSocketListener import org.amshove.kluent.`should be equal to` diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ChatSocketStateServiceTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ChatSocketStateServiceTest.kt index 480e46b3c6e..45cfe7785f8 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ChatSocketStateServiceTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ChatSocketStateServiceTest.kt @@ -21,7 +21,8 @@ import io.getstream.chat.android.client.events.ConnectedEvent import io.getstream.chat.android.client.socket.ChatSocketStateService import io.getstream.chat.android.client.socket.ChatSocketStateService.State import io.getstream.chat.android.client.socket.SocketFactory -import io.getstream.chat.android.test.randomBoolean +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomChatNetworkError import io.getstream.result.Error import kotlinx.coroutines.test.runTest import org.amshove.kluent.`should be equal to` @@ -249,13 +250,13 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, State.Disconnected.DisconnectedByRequest, ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedTemporarily(it), State.Disconnected.DisconnectedTemporarily(it), ) }, - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), State.Disconnected.DisconnectedPermanently(it), @@ -294,10 +295,10 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), State.Disconnected.NetworkDisconnected, ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), State.Disconnected.DisconnectedPermanently(it), @@ -336,11 +337,11 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedPermanently(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedPermanently(randomChatNetworkError()), State.Disconnected.DisconnectedByRequest, ), ) @@ -376,10 +377,10 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), State.Disconnected.Stopped, ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), State.Disconnected.DisconnectedPermanently(it), @@ -421,13 +422,13 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, State.Disconnected.DisconnectedByRequest, ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedTemporarily(it), State.Disconnected.DisconnectedTemporarily(it), ) }, - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), State.Disconnected.DisconnectedPermanently(it), @@ -466,10 +467,10 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), State.Disconnected.WebSocketEventLost, ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), State.Disconnected.DisconnectedPermanently(it), @@ -562,18 +563,18 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), newConnectionConf, true, State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.FORCE_RECONNECTION), ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), newConnectionConf, false, State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.AUTOMATIC_RECONNECTION), ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), newConnectionConf, @@ -581,7 +582,7 @@ internal class ChatSocketStateServiceTest { State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.FORCE_RECONNECTION), ) }, - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), newConnectionConf, @@ -633,11 +634,11 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), connectedEvent, State.Connected(connectedEvent), ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), connectedEvent, @@ -648,7 +649,7 @@ internal class ChatSocketStateServiceTest { } @JvmStatic - fun onUnrecoverableErrorArgs() = Mother.randomChatNetworkError().let { error -> + fun onUnrecoverableErrorArgs() = randomChatNetworkError().let { error -> listOf( Arguments.of( State.RestartConnection, @@ -686,11 +687,11 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), error, State.Disconnected.DisconnectedPermanently(error), ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), error, @@ -701,7 +702,7 @@ internal class ChatSocketStateServiceTest { } @JvmStatic - fun onNetworkErrorArgs() = Mother.randomChatNetworkError().let { error -> + fun onNetworkErrorArgs() = randomChatNetworkError().let { error -> listOf( Arguments.of( State.RestartConnection, @@ -739,11 +740,11 @@ internal class ChatSocketStateServiceTest { State.Disconnected.DisconnectedByRequest, ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), error, State.Disconnected.DisconnectedTemporarily(error), ), - Mother.randomChatNetworkError().let { + randomChatNetworkError().let { Arguments.of( State.Disconnected.DisconnectedPermanently(it), error, @@ -794,12 +795,12 @@ internal class ChatSocketStateServiceTest { State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.INITIAL_CONNECTION), ), Arguments.of( - State.Disconnected.DisconnectedTemporarily(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedTemporarily(randomChatNetworkError()), newConnectionConf, State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.INITIAL_CONNECTION), ), Arguments.of( - State.Disconnected.DisconnectedPermanently(Mother.randomChatNetworkError()), + State.Disconnected.DisconnectedPermanently(randomChatNetworkError()), newConnectionConf, State.Connecting(newConnectionConf, ChatSocketStateService.ConnectionType.INITIAL_CONNECTION), ), diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ws/StreamWebSocketTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ws/StreamWebSocketTest.kt index 4b9aa498aad..d9e05e798af 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ws/StreamWebSocketTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ws/StreamWebSocketTest.kt @@ -24,10 +24,10 @@ import io.getstream.chat.android.client.socket.ErrorResponse import io.getstream.chat.android.client.socket.SocketErrorMessage import io.getstream.chat.android.client.socket.StreamWebSocket import io.getstream.chat.android.client.socket.StreamWebSocketEvent -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.launch diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/token/CacheableTokenProviderTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/token/CacheableTokenProviderTest.kt index b4e65860549..039ee18a784 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/token/CacheableTokenProviderTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/token/CacheableTokenProviderTest.kt @@ -16,8 +16,8 @@ package io.getstream.chat.android.client.token -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomString import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test import org.mockito.kotlin.doReturn diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/user/CurrentUserFetcherTests.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/user/CurrentUserFetcherTests.kt index 40996bb18a0..78084a70835 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/user/CurrentUserFetcherTests.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/user/CurrentUserFetcherTests.kt @@ -28,10 +28,10 @@ import io.getstream.chat.android.client.socket.ErrorResponse import io.getstream.chat.android.client.socket.SocketErrorMessage import io.getstream.chat.android.client.socket.SocketFactory import io.getstream.chat.android.client.socket.StreamWebSocket -import io.getstream.chat.android.client.test.randomUser +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/TokenUtilsTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/TokenUtilsTest.kt index c754830d97f..f54fa9ab873 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/TokenUtilsTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/TokenUtilsTest.kt @@ -16,7 +16,7 @@ package io.getstream.chat.android.client.utils -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import org.amshove.kluent.`should be equal to` import org.junit.Test import org.junit.runner.RunWith diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/buffer/StartStopBufferTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/buffer/StartStopBufferTest.kt index e5037b3b7bb..ecd101e7e99 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/buffer/StartStopBufferTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/buffer/StartStopBufferTest.kt @@ -16,8 +16,8 @@ package io.getstream.chat.android.client.utils.buffer +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import org.amshove.kluent.`should be equal to` import org.amshove.kluent.`should be in` diff --git a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/observable/ChatEventsObservableTest.kt b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/observable/ChatEventsObservableTest.kt index 37a9b24c3a9..8199751fc5f 100644 --- a/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/observable/ChatEventsObservableTest.kt +++ b/stream-chat-android-client/src/test/java/io/getstream/chat/android/client/utils/observable/ChatEventsObservableTest.kt @@ -25,10 +25,10 @@ import io.getstream.chat.android.client.parser2.adapters.internal.StreamDateForm import io.getstream.chat.android.client.scope.ClientTestScope import io.getstream.chat.android.client.scope.UserTestScope import io.getstream.chat.android.client.socket.FakeChatSocket -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.client.token.FakeTokenManager +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import org.amshove.kluent.shouldBeEqualTo diff --git a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/MediaAttachmentPreviewHandlerTest.kt b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/MediaAttachmentPreviewHandlerTest.kt index 1be80683a27..c2ea061c3af 100644 --- a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/MediaAttachmentPreviewHandlerTest.kt +++ b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/MediaAttachmentPreviewHandlerTest.kt @@ -20,7 +20,7 @@ import android.content.Context import io.getstream.chat.android.compose.ui.attachments.preview.handler.MediaAttachmentPreviewHandler import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.AttachmentType -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import org.amshove.kluent.`should be equal to` import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-core/src/test/java/io.getstream.chat.android.client/Mother.kt b/stream-chat-android-core/src/test/java/io.getstream.chat.android.client/Mother.kt deleted file mode 100644 index d3a73575bd2..00000000000 --- a/stream-chat-android-core/src/test/java/io.getstream.chat.android.client/Mother.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014-2022 Stream.io Inc. All rights reserved. - * - * Licensed under the Stream License; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.getstream.chat.android.client - -import kotlin.random.Random - -private val charPool: CharArray = (('a'..'z') + ('A'..'Z') + ('0'..'9')).toCharArray() - -public fun positiveRandomInt(maxInt: Int = Int.MAX_VALUE - 1): Int = - Random.nextInt(1, maxInt + 1) - -public fun positiveRandomLong(maxLong: Long = Long.MAX_VALUE - 1): Long = - Random.nextLong(1, maxLong + 1) - -public fun randomInt(): Int = Random.nextInt() -public fun randomIntBetween(min: Int, max: Int): Int = Random.nextInt(min, max + 1) -public fun randomLong(): Long = Random.nextLong() -public fun randomLongBetween(min: Long, max: Long = Long.MAX_VALUE - 1): Long = Random.nextLong(min, max + 1) -public fun randomBoolean(): Boolean = Random.nextBoolean() -public fun randomString(size: Int = 20): String = buildString(capacity = size) { - repeat(size) { - append(charPool.random()) - } -} diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/Mother.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/Mother.kt index 71dadebd240..568c494acec 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/Mother.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/Mother.kt @@ -18,8 +18,6 @@ package io.getstream.chat.android.offline import androidx.room.Room import androidx.test.core.app.ApplicationProvider -import io.getstream.chat.android.client.extensions.EXTRA_UPLOAD_ID -import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.NeutralFilterObject @@ -33,31 +31,16 @@ import io.getstream.chat.android.offline.repository.domain.message.internal.Mess import io.getstream.chat.android.offline.repository.domain.queryChannels.internal.QueryChannelsEntity import io.getstream.chat.android.offline.repository.domain.reaction.internal.ReactionEntity import io.getstream.chat.android.offline.repository.domain.user.internal.UserEntity -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomFile -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomString import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.asExecutor import java.util.Date -import java.util.UUID import java.util.concurrent.Executors -internal fun randomAttachmentsWithFile( - size: Int = positiveRandomInt(10), - creationFunction: (Int) -> Attachment = { - Attachment( - upload = randomFile(), - extraData = mutableMapOf( - EXTRA_UPLOAD_ID to "upload_id_${UUID.randomUUID()}", - ), - ) - }, -): List = (1..size).map(creationFunction) - internal fun randomUserEntity( id: String = randomString(), originalId: String = randomString(), diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/PaginationTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/PaginationTest.kt index 33a18a9ffc7..9fb7874b187 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/PaginationTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/PaginationTest.kt @@ -18,12 +18,12 @@ package io.getstream.chat.android.offline import io.getstream.chat.android.client.extensions.internal.applyPagination import io.getstream.chat.android.client.query.pagination.AnyChannelPaginationRequest -import io.getstream.chat.android.client.test.randomChannel import io.getstream.chat.android.client.test.utils.calendar import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySortByField.Companion.ascByName import io.getstream.chat.android.models.querysort.QuerySortByField.Companion.descByName +import io.getstream.chat.android.randomChannel import org.amshove.kluent.`should be equal to` import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseDomainTest2.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseDomainTest2.kt index 1fd6f7dc9f2..e0a459a5f30 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseDomainTest2.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseDomainTest2.kt @@ -44,9 +44,9 @@ import io.getstream.chat.android.models.User import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.offline.repository.database.internal.ChatDatabase import io.getstream.chat.android.offline.repository.factory.internal.DatabaseRepositoryFactory +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCall import io.getstream.chat.android.test.TestCoroutineRule -import io.getstream.chat.android.test.randomString import io.getstream.result.Result import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseRepositoryFacadeIntegrationTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseRepositoryFacadeIntegrationTest.kt index 156115f033a..8965d2b10fd 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseRepositoryFacadeIntegrationTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/integration/BaseRepositoryFacadeIntegrationTest.kt @@ -19,10 +19,10 @@ package io.getstream.chat.android.offline.integration import androidx.annotation.CallSuper import androidx.arch.core.executor.testing.InstantTaskExecutorRule import io.getstream.chat.android.client.persistance.repository.RepositoryFacade -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.offline.createRoomDB import io.getstream.chat.android.offline.repository.database.internal.ChatDatabase import io.getstream.chat.android.offline.repository.factory.internal.DatabaseRepositoryFactory +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.After diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/CreateChannelTests.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/CreateChannelTests.kt index 1aa3044eaff..6fb9d87d1d7 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/CreateChannelTests.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/CreateChannelTests.kt @@ -18,11 +18,11 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.RepositoryFacade import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMember -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Member import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomUser import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteMessageListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteMessageListenerDatabaseTest.kt index 55ee0983c86..2753ffe2c21 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteMessageListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteMessageListenerDatabaseTest.kt @@ -19,10 +19,10 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.UserRepository import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.test.randomCID +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomUser import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.test.runTest diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteReactionListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteReactionListenerDatabaseTest.kt index 313be59d8ca..6f1f3e8a695 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteReactionListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/DeleteReactionListenerDatabaseTest.kt @@ -19,12 +19,12 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.ReactionRepository import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/EditMessageListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/EditMessageListenerDatabaseTest.kt index 2a8aa66fc54..4dd479ce8c4 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/EditMessageListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/EditMessageListenerDatabaseTest.kt @@ -20,8 +20,8 @@ import io.getstream.chat.android.client.extensions.internal.users import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.UserRepository import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomMessage import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/HideChannelListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/HideChannelListenerDatabaseTest.kt index 6bdc9642f37..03587eb6355 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/HideChannelListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/HideChannelListenerDatabaseTest.kt @@ -20,8 +20,8 @@ import io.getstream.chat.android.client.extensions.cidToTypeAndId import io.getstream.chat.android.client.extensions.internal.toCid import io.getstream.chat.android.client.persistance.repository.ChannelRepository import io.getstream.chat.android.client.persistance.repository.MessageRepository -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomCID import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/QueryMembersListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/QueryMembersListenerDatabaseTest.kt index 41bdbf29a51..c4e97c1e9fc 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/QueryMembersListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/QueryMembersListenerDatabaseTest.kt @@ -19,12 +19,12 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.extensions.cidToTypeAndId import io.getstream.chat.android.client.persistance.repository.ChannelRepository import io.getstream.chat.android.client.persistance.repository.UserRepository -import io.getstream.chat.android.client.test.randomMember import io.getstream.chat.android.models.Filters import io.getstream.chat.android.models.Member import io.getstream.chat.android.models.querysort.QuerySortByField -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomInt +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomMember import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendMessageListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendMessageListenerDatabaseTest.kt index f29b49a3b25..5f4680639ed 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendMessageListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendMessageListenerDatabaseTest.kt @@ -19,9 +19,9 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.extensions.internal.users import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.UserRepository -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendReactionListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendReactionListenerDatabaseTest.kt index 277ab5fe8ad..ef1ddf7933b 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendReactionListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/SendReactionListenerDatabaseTest.kt @@ -20,12 +20,12 @@ import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.ReactionRepository import io.getstream.chat.android.client.persistance.repository.UserRepository import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.randomCID +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomUser import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ShuffleGiphyListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ShuffleGiphyListenerDatabaseTest.kt index 617c97317a4..1b5c9d781fc 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ShuffleGiphyListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ShuffleGiphyListenerDatabaseTest.kt @@ -18,9 +18,9 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.UserRepository -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.test.randomCID +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ThreadQueryListenerDatabaseTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ThreadQueryListenerDatabaseTest.kt index 15c289bcac5..557eb6b93b4 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ThreadQueryListenerDatabaseTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/plugin/listener/internal/ThreadQueryListenerDatabaseTest.kt @@ -18,9 +18,9 @@ package io.getstream.chat.android.offline.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.persistance.repository.UserRepository -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ChannelConfigRepositoryTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ChannelConfigRepositoryTest.kt index 0841af6f50f..54d44f1677b 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ChannelConfigRepositoryTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ChannelConfigRepositoryTest.kt @@ -17,17 +17,17 @@ package io.getstream.chat.android.offline.repository import io.getstream.chat.android.client.persistance.repository.ChannelConfigRepository -import io.getstream.chat.android.client.test.randomChannelConfig -import io.getstream.chat.android.client.test.randomConfig import io.getstream.chat.android.offline.repository.domain.channelconfig.internal.ChannelConfigDao import io.getstream.chat.android.offline.repository.domain.channelconfig.internal.ChannelConfigEntity import io.getstream.chat.android.offline.repository.domain.channelconfig.internal.ChannelConfigInnerEntity import io.getstream.chat.android.offline.repository.domain.channelconfig.internal.DatabaseChannelConfigRepository +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomChannelConfig +import io.getstream.chat.android.randomConfig +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomString import io.getstream.chat.android.test.TestCoroutineRule -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/MessageRepositoryTests.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/MessageRepositoryTests.kt index 7f641e6dcf4..6bd69046fdd 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/MessageRepositoryTests.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/MessageRepositoryTests.kt @@ -20,14 +20,14 @@ import androidx.collection.LruCache import io.getstream.chat.android.client.api.models.Pagination import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.query.pagination.AnyChannelPaginationRequest -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Message import io.getstream.chat.android.offline.randomMessageEntity import io.getstream.chat.android.offline.repository.domain.message.internal.DatabaseMessageRepository import io.getstream.chat.android.offline.repository.domain.message.internal.MessageDao import io.getstream.chat.android.offline.repository.domain.message.internal.ReplyMessageDao -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ReactionRepositoryTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ReactionRepositoryTest.kt index b8d09cf2fa5..93b9516cfc6 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ReactionRepositoryTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/ReactionRepositoryTest.kt @@ -17,15 +17,15 @@ package io.getstream.chat.android.offline.repository import io.getstream.chat.android.client.persistance.repository.ReactionRepository -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.User import io.getstream.chat.android.offline.repository.domain.reaction.internal.DatabaseReactionRepository import io.getstream.chat.android.offline.repository.domain.reaction.internal.ReactionDao import io.getstream.chat.android.offline.repository.domain.reaction.internal.toEntity +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineRule -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.amshove.kluent.coInvoking diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/UserRepositoryTests.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/UserRepositoryTests.kt index c01ae9cf4e8..2c8f289a6c5 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/UserRepositoryTests.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/UserRepositoryTests.kt @@ -18,10 +18,10 @@ package io.getstream.chat.android.offline.repository import app.cash.turbine.test import io.getstream.chat.android.client.persistance.repository.UserRepository -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.User import io.getstream.chat.android.offline.repository.domain.user.internal.DatabaseUserRepository import io.getstream.chat.android.offline.repository.domain.user.internal.UserDao +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.drop diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/database/converter/FilterObjectConverterTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/database/converter/FilterObjectConverterTest.kt index 321469c7112..0b90f2dfe16 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/database/converter/FilterObjectConverterTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/database/converter/FilterObjectConverterTest.kt @@ -19,10 +19,10 @@ package io.getstream.chat.android.offline.repository.database.converter import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.Filters import io.getstream.chat.android.offline.repository.database.converter.internal.FilterObjectConverter -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomString import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/ChannelRepositoryImplTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/ChannelRepositoryImplTest.kt index a2393c2a251..6177d446dae 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/ChannelRepositoryImplTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/ChannelRepositoryImplTest.kt @@ -18,9 +18,9 @@ package io.getstream.chat.android.offline.repository.domain.channel.internal -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomUser import io.getstream.chat.android.test.TestCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryTest.kt index cccc3fb5e7c..aa0e0f2269d 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryTest.kt @@ -16,12 +16,12 @@ package io.getstream.chat.android.offline.repository.domain.channel.internal -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test import org.mockito.kotlin.argThat diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/facade/RepositoryFacadeIntegrationTests.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/facade/RepositoryFacadeIntegrationTests.kt index dba117907b3..4d7aae945cd 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/facade/RepositoryFacadeIntegrationTests.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/facade/RepositoryFacadeIntegrationTests.kt @@ -17,13 +17,13 @@ package io.getstream.chat.android.offline.repository.facade import androidx.test.ext.junit.runners.AndroidJUnit4 -import io.getstream.chat.android.client.test.randomChannelInfo -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Message import io.getstream.chat.android.offline.integration.BaseRepositoryFacadeIntegrationTest -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomChannelInfo +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEmpty import org.amshove.kluent.shouldBeEqualTo diff --git a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/integration/MessageRepositoryTest.kt b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/integration/MessageRepositoryTest.kt index d927ac0bc6e..95dfa3150b5 100644 --- a/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/integration/MessageRepositoryTest.kt +++ b/stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/integration/MessageRepositoryTest.kt @@ -18,10 +18,10 @@ package io.getstream.chat.android.offline.repository.integration import android.database.sqlite.SQLiteException import androidx.test.ext.junit.runners.AndroidJUnit4 -import io.getstream.chat.android.client.test.randomAttachment -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.offline.integration.BaseDomainTest2 -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomAttachment +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import kotlinx.coroutines.test.runTest import org.amshove.kluent.coInvoking import org.amshove.kluent.`should be equal to` @@ -35,9 +35,9 @@ internal class MessageRepositoryTest : BaseDomainTest2() { @Test fun `Given message with 3 attachments When update it in DB Should keep only 3 newer attachments`(): Unit = runTest { - val attachment1 = randomAttachment().copy(url = "url1") - val attachment2 = randomAttachment().copy(url = "url2") - val attachment3 = randomAttachment().copy(url = "url3") + val attachment1 = randomAttachment(url = "url1") + val attachment2 = randomAttachment(url = "url2") + val attachment3 = randomAttachment(url = "url3") val message = randomMessage(attachments = mutableListOf(attachment1, attachment2, attachment3)) repos.insertMessage(message) diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/AttachmentUrlValidatorTests.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/AttachmentUrlValidatorTests.kt index 39855379edb..c64bad6a960 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/AttachmentUrlValidatorTests.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/AttachmentUrlValidatorTests.kt @@ -17,9 +17,9 @@ package io.getstream.chat.android.state.channel import io.getstream.chat.android.client.helpers.AttachmentHelper -import io.getstream.chat.android.client.test.randomAttachment -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.Attachment +import io.getstream.chat.android.randomAttachment +import io.getstream.chat.android.randomMessage import io.getstream.chat.android.state.message.attachments.internal.AttachmentUrlValidator import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeTrue @@ -152,7 +152,7 @@ internal class AttachmentUrlValidatorTests { @Test fun `Given attachments with not stream imageUrls and valid old urls Should Not return attachment with old url`() { - val oldAttachment = randomAttachment().copy(imageUrl = "oldUrl") + val oldAttachment = randomAttachment(imageUrl = "oldUrl") val newAttachment = oldAttachment.copy(imageUrl = "newUrl") val oldMessage = randomMessage(attachments = mutableListOf(oldAttachment)) val newMessage = oldMessage.copy(attachments = mutableListOf(newAttachment)) diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/WhenHandleEvent.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/WhenHandleEvent.kt index 7b4233bbcec..e901beafefa 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/WhenHandleEvent.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/WhenHandleEvent.kt @@ -19,9 +19,7 @@ package io.getstream.chat.android.state.channel.controller import io.getstream.chat.android.client.persistance.repository.RepositoryFacade import io.getstream.chat.android.client.test.SynchronizedCoroutineTest import io.getstream.chat.android.client.test.randomChannelDeletedEvent -import io.getstream.chat.android.client.test.randomMember import io.getstream.chat.android.client.test.randomMemberAddedEvent -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.client.test.randomMessageReadEvent import io.getstream.chat.android.client.test.randomMessageUpdateEvent import io.getstream.chat.android.client.test.randomNewMessageEvent @@ -29,15 +27,17 @@ import io.getstream.chat.android.client.test.randomNotificationMarkReadEvent import io.getstream.chat.android.client.test.randomReactionNewEvent import io.getstream.chat.android.client.test.randomTypingStartEvent import io.getstream.chat.android.client.test.randomTypingStopEvent -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.message.attachments.internal.AttachmentUrlValidator import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.state.channel.internal.ChannelMutableState import io.getstream.chat.android.test.TestCoroutineRule -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/UploadAttachmentsIntegrationTests.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/UploadAttachmentsIntegrationTests.kt index 09d5ae06b43..bccee43b364 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/UploadAttachmentsIntegrationTests.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/UploadAttachmentsIntegrationTests.kt @@ -25,19 +25,19 @@ import io.getstream.chat.android.client.attachment.AttachmentUploader import io.getstream.chat.android.client.attachment.worker.UploadAttachmentsWorker import io.getstream.chat.android.client.persistance.repository.MessageRepository import io.getstream.chat.android.client.query.pagination.AnyChannelPaginationRequest -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.UploadedFile import io.getstream.chat.android.models.UploadedImage +import io.getstream.chat.android.randomAttachmentsWithFile +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry import io.getstream.chat.android.state.plugin.state.channel.internal.ChannelMutableState -import io.getstream.chat.android.state.utils.randomAttachmentsWithFile import io.getstream.chat.android.test.TestCall import io.getstream.chat.android.test.TestCoroutineRule -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/WhenUploadAttachmentsTests.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/WhenUploadAttachmentsTests.kt index 8a71fc2bd51..dc83007d5f6 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/WhenUploadAttachmentsTests.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/attachment/WhenUploadAttachmentsTests.kt @@ -22,14 +22,14 @@ import io.getstream.chat.android.client.attachment.worker.UploadAttachmentsWorke import io.getstream.chat.android.client.extensions.EXTRA_UPLOAD_ID import io.getstream.chat.android.client.extensions.uploadId import io.getstream.chat.android.client.persistance.repository.MessageRepository -import io.getstream.chat.android.client.test.randomAttachment -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.positiveRandomLong +import io.getstream.chat.android.randomAttachment +import io.getstream.chat.android.randomMessage import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.state.channel.internal.ChannelMutableState -import io.getstream.chat.android.test.positiveRandomLong import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/events/TypingEventsTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/events/TypingEventsTest.kt index 6332c06e577..1c8b9851c58 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/events/TypingEventsTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/events/TypingEventsTest.kt @@ -17,9 +17,9 @@ package io.getstream.chat.android.state.events import io.getstream.chat.android.client.plugin.listeners.TypingEventListener -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.EventType import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.plugin.listener.internal.TypingEventListenerState import io.getstream.chat.android.state.plugin.state.StateRegistry import io.getstream.chat.android.test.TestCoroutineExtension diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/RepositoryFacadeTests.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/RepositoryFacadeTests.kt index 1e5888f3904..afc5c2e091d 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/RepositoryFacadeTests.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/RepositoryFacadeTests.kt @@ -17,12 +17,6 @@ package io.getstream.chat.android.state.facade import io.getstream.chat.android.client.query.pagination.AnyChannelPaginationRequest -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomConfig -import io.getstream.chat.android.client.test.randomMember -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.ChannelConfig import io.getstream.chat.android.models.ChannelUserRead @@ -30,9 +24,15 @@ import io.getstream.chat.android.models.Member import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.Reaction import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomConfig +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomUser import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.amshove.kluent.`should be equal to` diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenEnrichChannel.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenEnrichChannel.kt index fa21535dac5..5a6305a75e3 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenEnrichChannel.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenEnrichChannel.kt @@ -16,10 +16,10 @@ package io.getstream.chat.android.state.facade -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.ChannelConfig import io.getstream.chat.android.models.Config +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenUpdateLastMessage.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenUpdateLastMessage.kt index 9960993c498..8cf0e391491 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenUpdateLastMessage.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/facade/WhenUpdateLastMessage.kt @@ -16,8 +16,8 @@ package io.getstream.chat.android.state.facade -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/DeleteReactionErrorHandlerImplTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/DeleteReactionErrorHandlerImplTest.kt index 6b8722d544d..8d5995cf40b 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/DeleteReactionErrorHandlerImplTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/DeleteReactionErrorHandlerImplTest.kt @@ -16,11 +16,11 @@ package io.getstream.chat.android.state.internal -import io.getstream.chat.android.client.test.randomMessage +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.errorhandler.internal.DeleteReactionErrorHandlerImpl import io.getstream.chat.android.test.TestCall import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomString import io.getstream.result.Result import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/SyncManagerTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/SyncManagerTest.kt index ed8e07cf3f9..2f1a343b8da 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/SyncManagerTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/SyncManagerTest.kt @@ -24,21 +24,21 @@ import io.getstream.chat.android.client.parser2.adapters.internal.StreamDateForm import io.getstream.chat.android.client.persistance.repository.RepositoryFacade import io.getstream.chat.android.client.setup.state.ClientState import io.getstream.chat.android.client.sync.SyncState -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.core.internal.coroutines.Tube import io.getstream.chat.android.models.ConnectionState import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry import io.getstream.chat.android.state.plugin.state.StateRegistry import io.getstream.chat.android.state.sync.internal.SyncManager import io.getstream.chat.android.test.TestCall import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomString import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/TypingEventPrunerTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/TypingEventPrunerTest.kt index 69aee4c7d2f..18e8f70e358 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/TypingEventPrunerTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/TypingEventPrunerTest.kt @@ -18,8 +18,8 @@ package io.getstream.chat.android.state.internal import io.getstream.chat.android.client.events.TypingStartEvent import io.getstream.chat.android.client.test.randomTypingStartEvent -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.TypingEvent +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.plugin.logic.channel.internal.TypingEventPruner import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.advanceTimeBy diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ChannelExtensionsTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ChannelExtensionsTest.kt index cefc5e9c87c..c145a8bc3b4 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ChannelExtensionsTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ChannelExtensionsTest.kt @@ -24,11 +24,11 @@ import com.squareup.moshi.adapter import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import io.getstream.chat.android.client.extensions.internal.applyPagination import io.getstream.chat.android.client.parser2.adapters.DateAdapter -import io.getstream.chat.android.client.test.randomChannel import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.MessageSyncContent import io.getstream.chat.android.models.querysort.QuerySortByField +import io.getstream.chat.android.randomChannel import io.getstream.chat.android.state.model.querychannels.pagination.internal.QueryChannelsPaginationRequest import io.getstream.chat.android.state.model.querychannels.pagination.internal.toAnyChannelPaginationRequest import okio.buffer diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/MemberExtensionsTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/MemberExtensionsTest.kt index 7fef94445f5..46eb5bd37b2 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/MemberExtensionsTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/MemberExtensionsTest.kt @@ -17,8 +17,8 @@ package io.getstream.chat.android.state.internal.extensions import io.getstream.chat.android.client.extensions.internal.updateUsers -import io.getstream.chat.android.client.test.randomMember -import io.getstream.chat.android.client.test.randomUser +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomUser import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ReactionExtensionsTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ReactionExtensionsTest.kt index b6f7e068e52..d4aba40014c 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ReactionExtensionsTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/internal/extensions/ReactionExtensionsTest.kt @@ -17,7 +17,7 @@ package io.getstream.chat.android.state.internal.extensions import io.getstream.chat.android.client.extensions.internal.mergeReactions -import io.getstream.chat.android.client.test.randomReaction +import io.getstream.chat.android.randomReaction import org.amshove.kluent.`should be equal to` import org.amshove.kluent.`should contain` import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteMessageListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteMessageListenerStateTest.kt index b5db71867fb..4d81435df05 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteMessageListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteMessageListenerStateTest.kt @@ -17,14 +17,14 @@ package io.getstream.chat.android.state.plugin.listener.internal import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry import io.getstream.chat.android.state.plugin.state.global.GlobalState -import io.getstream.chat.android.test.randomCID import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteReactionListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteReactionListenerStateTest.kt index 204b18e3f9f..97a5015057a 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteReactionListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/DeleteReactionListenerStateTest.kt @@ -17,12 +17,12 @@ package io.getstream.chat.android.state.plugin.listener.internal import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction -import io.getstream.chat.android.client.test.randomUser +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry -import io.getstream.chat.android.test.randomCID import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/EditMessageListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/EditMessageListenerStateTest.kt index 4a374fe871c..91345016e14 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/EditMessageListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/EditMessageListenerStateTest.kt @@ -17,8 +17,8 @@ package io.getstream.chat.android.state.plugin.listener.internal import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomMessage import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.logic.channel.thread.internal.ThreadLogic diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/HideChannelListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/HideChannelListenerStateTest.kt index 5c88e4692a6..c74074c44e3 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/HideChannelListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/HideChannelListenerStateTest.kt @@ -16,11 +16,11 @@ package io.getstream.chat.android.state.plugin.listener.internal +import io.getstream.chat.android.randomBoolean +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelStateLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/SendMessageListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/SendMessageListenerStateTest.kt index 33f048fcf71..c4d831079d3 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/SendMessageListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/SendMessageListenerStateTest.kt @@ -16,12 +16,12 @@ package io.getstream.chat.android.state.plugin.listener.internal -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.channel.thread.internal.ThreadLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ShuffleGiphyListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ShuffleGiphyListenerStateTest.kt index d5c1778a019..27848a0d152 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ShuffleGiphyListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ShuffleGiphyListenerStateTest.kt @@ -16,11 +16,11 @@ package io.getstream.chat.android.state.plugin.listener.internal -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry -import io.getstream.chat.android.test.randomCID import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ThreadQueryListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ThreadQueryListenerStateTest.kt index 134ce8f32d2..0c6b13a043e 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ThreadQueryListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/listener/internal/ThreadQueryListenerStateTest.kt @@ -17,11 +17,11 @@ package io.getstream.chat.android.state.plugin.listener.internal import io.getstream.chat.android.client.persistance.repository.MessageRepository -import io.getstream.chat.android.client.test.randomMessage +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.plugin.logic.channel.thread.internal.ThreadLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString import io.getstream.result.Error import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogicTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogicTest.kt index 14b58490eba..ef370d16687 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogicTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogicTest.kt @@ -20,29 +20,29 @@ import io.getstream.chat.android.client.api.models.Pagination import io.getstream.chat.android.client.api.models.QueryChannelRequest import io.getstream.chat.android.client.extensions.internal.NEVER import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.client.test.randomNewMessageEvent import io.getstream.chat.android.client.test.randomTypingStartEvent -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.ChannelData import io.getstream.chat.android.models.ChannelUserRead import io.getstream.chat.android.models.Config import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.User +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomDateAfter +import io.getstream.chat.android.randomDateBefore +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.message.attachments.internal.AttachmentUrlValidator import io.getstream.chat.android.state.model.querychannels.pagination.internal.QueryChannelPaginationRequest import io.getstream.chat.android.state.plugin.state.channel.internal.ChannelMutableState import io.getstream.chat.android.state.plugin.state.global.internal.MutableGlobalState import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomDateAfter -import io.getstream.chat.android.test.randomDateBefore -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import org.amshove.kluent.`should be equal to` diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querychannels/internal/QueryChannelsStateLogicTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querychannels/internal/QueryChannelsStateLogicTest.kt index 8ec266cf7ed..7c92d7ba698 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querychannels/internal/QueryChannelsStateLogicTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querychannels/internal/QueryChannelsStateLogicTest.kt @@ -20,14 +20,14 @@ import io.getstream.chat.android.client.channel.state.ChannelState import io.getstream.chat.android.client.extensions.cidToTypeAndId import io.getstream.chat.android.client.extensions.internal.toCid import io.getstream.chat.android.client.query.QueryChannelsSpec -import io.getstream.chat.android.client.test.randomChannel import io.getstream.chat.android.models.Filters import io.getstream.chat.android.models.querysort.QuerySortByField +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomString import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry import io.getstream.chat.android.state.plugin.state.StateRegistry import io.getstream.chat.android.state.plugin.state.querychannels.internal.QueryChannelsMutableState -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomString import org.amshove.kluent.`should contain same` import org.junit.jupiter.api.Test import org.mockito.kotlin.any diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/DefaultChatEventHandlerTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/DefaultChatEventHandlerTest.kt index d6239e0b5a0..b6b9fcccf59 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/DefaultChatEventHandlerTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/DefaultChatEventHandlerTest.kt @@ -17,20 +17,20 @@ package io.getstream.chat.android.state.querychannels import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMember import io.getstream.chat.android.client.test.randomMemberAddedEvent import io.getstream.chat.android.client.test.randomMemberRemovedEvent -import io.getstream.chat.android.client.test.randomMessage import io.getstream.chat.android.client.test.randomNewMessageEvent import io.getstream.chat.android.client.test.randomNotificationAddedToChannelEvent import io.getstream.chat.android.client.test.randomNotificationMessageNewEvent import io.getstream.chat.android.client.test.randomNotificationRemovedFromChannelEvent -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Filters +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.event.handler.chat.DefaultChatEventHandler import io.getstream.chat.android.state.event.handler.chat.EventHandlingResult -import io.getstream.chat.android.test.randomCID import kotlinx.coroutines.flow.MutableStateFlow import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/QueryChannelsSortTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/QueryChannelsSortTest.kt index b316667fb24..be138b0e588 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/QueryChannelsSortTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/querychannels/QueryChannelsSortTest.kt @@ -16,11 +16,11 @@ package io.getstream.chat.android.state.querychannels -import io.getstream.chat.android.client.test.randomChannel import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.CustomObject import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySortByField.Companion.ascByName +import io.getstream.chat.android.randomChannel import org.amshove.kluent.`should be equal to` import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/reactions/SendReactionListenerStateTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/reactions/SendReactionListenerStateTest.kt index 25186b06286..aad8683f982 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/reactions/SendReactionListenerStateTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/reactions/SendReactionListenerStateTest.kt @@ -17,16 +17,16 @@ package io.getstream.chat.android.state.reactions import io.getstream.chat.android.client.setup.state.ClientState -import io.getstream.chat.android.client.test.randomMessage -import io.getstream.chat.android.client.test.randomReaction import io.getstream.chat.android.models.Reaction import io.getstream.chat.android.models.SyncStatus import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomCID +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomReaction import io.getstream.chat.android.state.plugin.listener.internal.SendReactionListenerState import io.getstream.chat.android.state.plugin.logic.channel.internal.ChannelLogic import io.getstream.chat.android.state.plugin.logic.internal.LogicRegistry import io.getstream.chat.android.test.TestCoroutineExtension -import io.getstream.chat.android.test.randomCID import io.getstream.result.Result import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/CustomObjectFilteringTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/CustomObjectFilteringTest.kt index 806d3313936..b3ecf19e1fe 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/CustomObjectFilteringTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/CustomObjectFilteringTest.kt @@ -16,23 +16,23 @@ package io.getstream.chat.android.state.utils -import io.getstream.chat.android.client.test.randomChannel -import io.getstream.chat.android.client.test.randomMember -import io.getstream.chat.android.client.test.randomSyncStatus -import io.getstream.chat.android.client.test.randomUser import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.CustomObject import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.Filters import io.getstream.chat.android.models.NeutralFilterObject import io.getstream.chat.android.models.SyncStatus +import io.getstream.chat.android.positiveRandomInt +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomInt +import io.getstream.chat.android.randomIntBetween +import io.getstream.chat.android.randomLong +import io.getstream.chat.android.randomLongBetween +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomString +import io.getstream.chat.android.randomSyncStatus +import io.getstream.chat.android.randomUser import io.getstream.chat.android.state.utils.internal.filter -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomIntBetween -import io.getstream.chat.android.test.randomLong -import io.getstream.chat.android.test.randomLongBetween -import io.getstream.chat.android.test.randomString import org.amshove.kluent.shouldContainSame import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/Mother.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/Mother.kt deleted file mode 100644 index 4ccdf4bfb60..00000000000 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/state/utils/Mother.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2014-2022 Stream.io Inc. All rights reserved. - * - * Licensed under the Stream License; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.getstream.chat.android.state.utils - -import io.getstream.chat.android.client.extensions.EXTRA_UPLOAD_ID -import io.getstream.chat.android.models.Attachment -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomFile -import java.util.UUID - -internal fun randomAttachmentsWithFile( - size: Int = positiveRandomInt(10), - createAttachment: (Int) -> Attachment = { - Attachment( - upload = randomFile(), - extraData = mapOf(EXTRA_UPLOAD_ID to "upload_id_${UUID.randomUUID()}"), - ) - }, -): List = (1..size).map(createAttachment) diff --git a/stream-chat-android-test/src/main/java/io/getstream/chat/android/test/Mother.kt b/stream-chat-android-test/src/main/java/io/getstream/chat/android/test/Mother.kt deleted file mode 100644 index 70a5950e0e2..00000000000 --- a/stream-chat-android-test/src/main/java/io/getstream/chat/android/test/Mother.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2014-2022 Stream.io Inc. All rights reserved. - * - * Licensed under the Stream License; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.getstream.chat.android.test - -import java.io.File -import java.util.Calendar -import java.util.Date -import kotlin.random.Random - -private val charPool: CharArray = (('a'..'z') + ('A'..'Z') + ('0'..'9')).toCharArray() - -public fun positiveRandomInt(maxInt: Int = Int.MAX_VALUE - 1): Int = - Random.nextInt(1, maxInt + 1) - -public fun positiveRandomLong(maxLong: Long = Long.MAX_VALUE - 1): Long = - Random.nextLong(1, maxLong + 1) - -public fun randomInt(): Int = Random.nextInt() -public fun randomIntBetween(min: Int, max: Int): Int = Random.nextInt(min, max + 1) -public fun randomLong(): Long = Random.nextLong() -public fun randomLongBetween(min: Long, max: Long = Long.MAX_VALUE - 1): Long = Random.nextLong(min, max + 1) -public fun randomBoolean(): Boolean = Random.nextBoolean() -public fun randomString(size: Int = 20): String = buildString(capacity = size) { - repeat(size) { - append(charPool.random()) - } -} -public fun randomCID(): String = "${randomString()}:${randomString()}" - -public fun randomFile(extension: String = randomString(3)): File { - return File("${randomString()}.$extension") -} - -public fun randomImageFile(): File = randomFile(extension = "jpg") - -public fun randomFiles( - size: Int = positiveRandomInt(10), - creationFunction: (Int) -> File = { randomFile() }, -): List = (1..size).map(creationFunction) - -public fun randomDate(): Date = Date(positiveRandomLong()) -public fun randomDateBefore(date: Long): Date = Date(date - positiveRandomInt()) -public fun randomDateAfter(date: Long): Date = Date(randomLongBetween(date)) - -public fun createDate( - year: Int = positiveRandomInt(), - month: Int = positiveRandomInt(), - date: Int = positiveRandomInt(), - hourOfDay: Int = 0, - minute: Int = 0, - seconds: Int = 0, -): Date { - val calendar = Calendar.getInstance() - calendar.set(year, month, date, hourOfDay, minute, seconds) - return calendar.time -} - -public fun randomValue(): Any { - return when (Random.nextInt(0, 5)) { - 0 -> randomString() - 1 -> randomInt() - 2 -> randomLong() - 3 -> randomBoolean() - 4 -> randomDate() - else -> randomString() - } -} -public fun randomExtraData(maxPossibleEntries: Int = 10): Map { - val size = positiveRandomInt(maxPossibleEntries) - return (1..size).associate { randomString() to randomValue() } -} diff --git a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/Mother.kt b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/Mother.kt deleted file mode 100644 index 59c9102824f..00000000000 --- a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/Mother.kt +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2014-2022 Stream.io Inc. All rights reserved. - * - * Licensed under the Stream License; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.getstream.chat.android.ui.common - -import io.getstream.chat.android.models.Attachment -import io.getstream.chat.android.models.Channel -import io.getstream.chat.android.models.ChannelMute -import io.getstream.chat.android.models.ChannelUserRead -import io.getstream.chat.android.models.Command -import io.getstream.chat.android.models.Config -import io.getstream.chat.android.models.Device -import io.getstream.chat.android.models.Member -import io.getstream.chat.android.models.Message -import io.getstream.chat.android.models.Mute -import io.getstream.chat.android.models.Reaction -import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString -import java.io.File -import java.time.Instant -import java.util.Date - -internal fun createUser( - id: String = randomString(), - name: String = randomString(), - image: String = randomString(), - role: String = randomString(), - invisible: Boolean = randomBoolean(), - banned: Boolean = randomBoolean(), - devices: List = mutableListOf(), - online: Boolean = randomBoolean(), - createdAt: Date? = randomDate(), - deactivatedAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - lastActive: Date? = randomDate(), - totalUnreadCount: Int = positiveRandomInt(), - unreadChannels: Int = positiveRandomInt(), - mutes: List = mutableListOf(), - teams: List = listOf(), - channelMutes: List = emptyList(), - extraData: MutableMap = mutableMapOf(), -): User = User( - id = id, - name = name, - image = image, - role = role, - invisible = invisible, - banned = banned, - devices = devices, - online = online, - createdAt = createdAt, - deactivatedAt = deactivatedAt, - updatedAt = updatedAt, - lastActive = lastActive, - totalUnreadCount = totalUnreadCount, - unreadChannels = unreadChannels, - mutes = mutes, - teams = teams, - channelMutes = channelMutes, - extraData = extraData, -) - -internal fun createChannel( - config: Config = Config(), - extraData: MutableMap = mutableMapOf(), -): Channel = - Channel(config = config, extraData = extraData) - -internal fun createMessage( - id: String = randomString(), - cid: String = randomCID(), - text: String = randomString(), - html: String = randomString(), - parentId: String? = randomString(), - command: String? = randomString(), - attachments: MutableList = mutableListOf(), - mentionedUsers: MutableList = mutableListOf(), - replyCount: Int = randomInt(), - reactionCounts: MutableMap = mutableMapOf(), - reactionScores: MutableMap = mutableMapOf(), - syncStatus: SyncStatus = randomSyncStatus(), - type: String = randomString(), - latestReactions: MutableList = mutableListOf(), - ownReactions: MutableList = mutableListOf(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - user: User = createUser(), - extraData: MutableMap = mutableMapOf(), - silent: Boolean = randomBoolean(), -): Message = Message( - id = id, - cid = cid, - text = text, - html = html, - parentId = parentId, - command = command, - attachments = attachments, - mentionedUsers = mentionedUsers, - replyCount = replyCount, - reactionCounts = reactionCounts, - reactionScores = reactionScores, - syncStatus = syncStatus, - type = type, - latestReactions = latestReactions, - ownReactions = ownReactions, - createdAt = createdAt, - updatedAt = updatedAt, - deletedAt = deletedAt, - user = user, - extraData = extraData, - silent = silent, -) - -internal fun randomSyncStatus(): SyncStatus = SyncStatus.values().random() - -internal fun createMessageList( - size: Int = 10, - creationFunction: (Int) -> Message = { createMessage() }, -): List = List(size, creationFunction) - -internal fun createChannelUserRead( - user: User = createUser(), - lastReadDate: Date = Date.from(Instant.now()), - unreadMessages: Int = 0, -) = ChannelUserRead(user, lastReadDate, unreadMessages) - -internal fun createCommand( - name: String = randomString(), - description: String = randomString(), - args: String = randomString(), - set: String = randomString(), -): Command = Command(name, description, args, set) - -internal fun createMember( - user: User = createUser(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - isInvited: Boolean = randomBoolean(), - inviteAcceptedAt: Date? = randomDate(), - inviteRejectedAt: Date? = randomDate(), -): Member = Member(user, createdAt, updatedAt, isInvited, inviteAcceptedAt, inviteRejectedAt) - -internal fun createMembers( - size: Int = positiveRandomInt(10), - creationFunction: (Int) -> Member = { createMember() }, -): List = List(size, creationFunction) - -internal fun createAttachment( - authorName: String? = randomString(), - titleLink: String? = randomString(), - thumbUrl: String? = randomString(), - imageUrl: String? = randomString(), - assetUrl: String? = randomString(), - ogUrl: String? = randomString(), - mimeType: String? = randomString(), - fileSize: Int = randomInt(), - title: String? = randomString(), - text: String? = randomString(), - type: String? = randomString(), - image: String? = randomString(), - url: String? = randomString(), - name: String? = randomString(), - fallback: String? = randomString(), - uploadFile: File? = null, - uploadState: Attachment.UploadState? = null, - extraData: MutableMap = mutableMapOf(), - authorLink: String? = randomString(), -): Attachment = Attachment( - authorName = authorName, - authorLink = authorLink, - titleLink = titleLink, - thumbUrl = thumbUrl, - imageUrl = imageUrl, - assetUrl = assetUrl, - ogUrl = ogUrl, - mimeType = mimeType, - fileSize = fileSize, - title = title, - text = text, - type = type, - image = image, - url = url, - name = name, - fallback = fallback, - upload = uploadFile, - uploadState = uploadState, - extraData = extraData, -) - -internal fun createCommands(size: Int = 10): List = List(size) { createCommand() } diff --git a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.kt b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.kt index 81e2019e986..c41a06dbf30 100644 --- a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.kt +++ b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.kt @@ -20,6 +20,7 @@ import io.getstream.chat.android.client.ChatClient import io.getstream.chat.android.client.channel.state.ChannelState import io.getstream.chat.android.client.setup.state.ClientState import io.getstream.chat.android.client.utils.message.isDeleted +import io.getstream.chat.android.createDate import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.ChannelData import io.getstream.chat.android.models.Config @@ -27,15 +28,15 @@ import io.getstream.chat.android.models.InitializationState import io.getstream.chat.android.models.MessagesState import io.getstream.chat.android.models.TypingEvent import io.getstream.chat.android.models.User +import io.getstream.chat.android.randomDate +import io.getstream.chat.android.randomMessage +import io.getstream.chat.android.randomMessageList import io.getstream.chat.android.state.plugin.config.StatePluginConfig import io.getstream.chat.android.state.plugin.internal.StatePlugin import io.getstream.chat.android.state.plugin.state.StateRegistry import io.getstream.chat.android.state.plugin.state.global.GlobalState import io.getstream.chat.android.test.TestCoroutineExtension import io.getstream.chat.android.test.asCall -import io.getstream.chat.android.test.createDate -import io.getstream.chat.android.ui.common.createMessage -import io.getstream.chat.android.ui.common.createMessageList import io.getstream.chat.android.ui.common.state.messages.list.DateSeparatorItemState import io.getstream.chat.android.ui.common.state.messages.list.DeletedMessageVisibility import io.getstream.chat.android.ui.common.state.messages.list.MessageItemState @@ -98,7 +99,7 @@ internal class MessageListControllerTests { @Test fun `Given other users are typing When there are messages Should add typing indicator to end`() = runTest { - val messageState = MessagesState.Result(createMessageList()) + val messageState = MessagesState.Result(randomMessageList()) val controller = Fixture() .givenCurrentUser() .givenChannelQuery() @@ -118,7 +119,7 @@ internal class MessageListControllerTests { @Test fun `Given regular message followed and preceded by current user message When grouping messages Should add middle position to message`() = runTest { - val messages = createMessageList(3) { createMessage(user = user1) } + val messages = randomMessageList(3) { randomMessage(user = user1) } val messageState = MessagesState.Result(messages) val controller = Fixture() .givenCurrentUser() @@ -136,9 +137,9 @@ internal class MessageListControllerTests { fun `Given regular message followed and preceded by other user message When grouping messages Should add top and bottom positions to messages`() = runTest { var message = 0 - val messages = createMessageList(3) { + val messages = randomMessageList(3) { message++ - createMessage(user = if (message % 2 == 0) user1 else user2) + randomMessage(user = if (message % 2 == 0) user1 else user2) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -157,9 +158,9 @@ internal class MessageListControllerTests { fun `Given regular message followed by system message When grouping messages Should add bottom position to the regular message`() = runTest { var message = 0 - val messages = createMessageList(3) { + val messages = randomMessageList(3) { message++ - createMessage(user = if (message % 2 == 0) user1 else user2) + randomMessage(user = if (message % 2 == 0) user1 else user2) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -178,9 +179,9 @@ internal class MessageListControllerTests { @Test fun `Given date separators with time difference Should add 3 date separators`() = runTest { var message = 0 - val messages = createMessageList(3) { + val messages = randomMessageList(3) { message++ - createMessage(createdAt = createDate(2022, 5, message)) + randomMessage(createdAt = createDate(2022, 5, message)) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -197,9 +198,9 @@ internal class MessageListControllerTests { @Test fun `Given handler returns no date separators Should not add date separators`() = runTest { var message = 0 - val messages = createMessageList(3) { + val messages = randomMessageList(3) { message++ - createMessage(createdAt = createDate(2022, 5, message)) + randomMessage(createdAt = createDate(2022, 5, message)) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -217,9 +218,9 @@ internal class MessageListControllerTests { @Test fun `When deleted visibility is never When grouping messages Should not add any deleted messages`() = runTest { var message = 0 - val messages = createMessageList { + val messages = randomMessageList { message++ - createMessage(deletedAt = if (message % 2 == 0) createDate() else null) + randomMessage(deletedAt = if (message % 2 == 0) randomDate() else null) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -235,9 +236,9 @@ internal class MessageListControllerTests { @Test fun `When deleted visibility is always When grouping messages Should add all deleted messages`() = runTest { var message = 0 - val messages = createMessageList { + val messages = randomMessageList { message++ - createMessage(deletedAt = if (message % 2 == 0) createDate() else null) + randomMessage(deletedAt = if (message % 2 == 0) randomDate() else null) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -253,9 +254,9 @@ internal class MessageListControllerTests { @Test fun `When deleted visibility is current user When grouping messages Should not see other users deleted messages`() = runTest { var message = 0 - val messages = createMessageList { + val messages = randomMessageList { message++ - createMessage(deletedAt = if (message % 2 == 0) createDate() else null) + randomMessage(deletedAt = if (message % 2 == 0) randomDate() else null) } val messageState = MessagesState.Result(messages) val controller = Fixture() @@ -273,9 +274,9 @@ internal class MessageListControllerTests { fun `When footer visibility is with time difference When message is after specified time Show message footer`() = runTest { var message = 0 - val messages = createMessageList(3) { + val messages = randomMessageList(3) { message++ - createMessage(createdAt = createDate(2022, 5, message)) + randomMessage(createdAt = createDate(2022, 5, message)) } val messageState = MessagesState.Result(messages) val controller = Fixture() diff --git a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/StringUtilsTest.kt b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/StringUtilsTest.kt index 7b9c2741013..161caed60b5 100644 --- a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/StringUtilsTest.kt +++ b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/StringUtilsTest.kt @@ -16,7 +16,7 @@ package io.getstream.chat.android.ui.common.utils -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import io.getstream.chat.android.ui.common.helper.internal.StorageHelper.Companion.FILE_NAME_PREFIX import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.api.Test diff --git a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/Mother.kt b/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/Mother.kt deleted file mode 100644 index fea1b3382e1..00000000000 --- a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/Mother.kt +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2014-2022 Stream.io Inc. All rights reserved. - * - * Licensed under the Stream License; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.getstream.chat.android.ui - -import io.getstream.chat.android.models.Attachment -import io.getstream.chat.android.models.Channel -import io.getstream.chat.android.models.ChannelMute -import io.getstream.chat.android.models.ChannelUserRead -import io.getstream.chat.android.models.Config -import io.getstream.chat.android.models.Device -import io.getstream.chat.android.models.Member -import io.getstream.chat.android.models.Message -import io.getstream.chat.android.models.Mute -import io.getstream.chat.android.models.Reaction -import io.getstream.chat.android.models.SyncStatus -import io.getstream.chat.android.models.User -import io.getstream.chat.android.test.positiveRandomInt -import io.getstream.chat.android.test.randomBoolean -import io.getstream.chat.android.test.randomCID -import io.getstream.chat.android.test.randomDate -import io.getstream.chat.android.test.randomInt -import io.getstream.chat.android.test.randomString -import java.util.Date - -internal fun createMessage( - id: String = randomString(), - cid: String = randomCID(), - text: String = randomString(), - html: String = randomString(), - parentId: String? = randomString(), - command: String? = randomString(), - attachments: MutableList = mutableListOf(), - mentionedUsers: MutableList = mutableListOf(), - replyCount: Int = randomInt(), - reactionCounts: MutableMap = mutableMapOf(), - reactionScores: MutableMap = mutableMapOf(), - syncStatus: SyncStatus = randomSyncStatus(), - type: String = randomString(), - latestReactions: MutableList = mutableListOf(), - ownReactions: MutableList = mutableListOf(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - user: User = createUser(), - extraData: MutableMap = mutableMapOf(), - silent: Boolean = randomBoolean(), -): Message = Message( - id = id, - cid = cid, - text = text, - html = html, - parentId = parentId, - command = command, - attachments = attachments, - mentionedUsers = mentionedUsers, - replyCount = replyCount, - reactionCounts = reactionCounts, - reactionScores = reactionScores, - syncStatus = syncStatus, - type = type, - latestReactions = latestReactions, - ownReactions = ownReactions, - createdAt = createdAt, - updatedAt = updatedAt, - deletedAt = deletedAt, - user = user, - extraData = extraData, - silent = silent, -) - -internal fun randomUser( - id: String = randomString(), - name: String = randomString(), - image: String = randomString(), - role: String = randomString(), - invisible: Boolean = randomBoolean(), - banned: Boolean = randomBoolean(), - devices: List = mutableListOf(), - online: Boolean = randomBoolean(), - createdAt: Date? = null, - deactivatedAt: Date? = null, - updatedAt: Date? = null, - lastActive: Date? = null, - totalUnreadCount: Int = positiveRandomInt(), - unreadChannels: Int = positiveRandomInt(), - mutes: List = mutableListOf(), - teams: List = listOf(), - channelMutes: List = emptyList(), - extraData: MutableMap = mutableMapOf(), -): User = User( - id = id, - name = name, - image = image, - role = role, - invisible = invisible, - banned = banned, - devices = devices, - online = online, - createdAt = createdAt, - deactivatedAt = deactivatedAt, - updatedAt = updatedAt, - lastActive = lastActive, - totalUnreadCount = totalUnreadCount, - unreadChannels = unreadChannels, - mutes = mutes, - teams = teams, - channelMutes = channelMutes, - extraData = extraData, -) - -internal fun createUser( - id: String = randomString(), - name: String = randomString(), - image: String = randomString(), - role: String = randomString(), - invisible: Boolean = randomBoolean(), - banned: Boolean = randomBoolean(), - devices: List = mutableListOf(), - online: Boolean = randomBoolean(), - createdAt: Date? = randomDate(), - deactivatedAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - lastActive: Date? = randomDate(), - totalUnreadCount: Int = positiveRandomInt(), - unreadChannels: Int = positiveRandomInt(), - mutes: List = mutableListOf(), - teams: List = listOf(), - channelMutes: List = emptyList(), - extraData: MutableMap = mutableMapOf(), -): User = User( - id = id, - name = name, - image = image, - role = role, - invisible = invisible, - banned = banned, - devices = devices, - online = online, - createdAt = createdAt, - deactivatedAt = deactivatedAt, - updatedAt = updatedAt, - lastActive = lastActive, - totalUnreadCount = totalUnreadCount, - unreadChannels = unreadChannels, - mutes = mutes, - teams = teams, - channelMutes = channelMutes, - extraData = extraData, -) - -internal fun createMember( - user: User = createUser(), - createdAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - isInvited: Boolean = randomBoolean(), - inviteAcceptedAt: Date? = randomDate(), - inviteRejectedAt: Date? = randomDate(), -): Member = Member(user, createdAt, updatedAt, isInvited, inviteAcceptedAt, inviteRejectedAt) - -internal fun createMembers( - size: Int = positiveRandomInt(10), - creationFunction: (Int) -> Member = { createMember() }, -): List = List(size, creationFunction) - -internal fun randomChannel( - id: String = randomString(), - type: String = randomString(), - watcherCount: Int = randomInt(), - frozen: Boolean = randomBoolean(), - lastMessageAt: Date? = randomDate(), - createdAt: Date? = randomDate(), - deletedAt: Date? = randomDate(), - updatedAt: Date? = randomDate(), - syncStatus: SyncStatus = randomSyncStatus(), - memberCount: Int = randomInt(), - messages: List = mutableListOf(), - members: List = mutableListOf(), - watchers: List = mutableListOf(), - read: List = mutableListOf(), - config: Config = Config(), - createdBy: User = createUser(), - unreadCount: Int? = randomInt(), - team: String = randomString(), - hidden: Boolean? = randomBoolean(), - hiddenMessagesBefore: Date? = randomDate(), -): Channel = Channel( - id = id, - type = type, - watcherCount = watcherCount, - frozen = frozen, - lastMessageAt = lastMessageAt, - createdAt = createdAt, - deletedAt = deletedAt, - updatedAt = updatedAt, - syncStatus = syncStatus, - memberCount = memberCount, - messages = messages, - members = members, - watchers = watchers, - read = read, - config = config, - createdBy = createdBy, - unreadCount = unreadCount, - team = team, - hidden = hidden, - hiddenMessagesBefore = hiddenMessagesBefore, -) - -internal fun randomSyncStatus(exclude: List = emptyList()): SyncStatus = - (SyncStatus.values().asList() - exclude - SyncStatus.AWAITING_ATTACHMENTS).random() diff --git a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/ChannelKtTest.kt b/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/ChannelKtTest.kt index 77499e7cae7..d526f0b216a 100644 --- a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/ChannelKtTest.kt +++ b/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/ChannelKtTest.kt @@ -16,10 +16,10 @@ package io.getstream.chat.android.ui.utils +import io.getstream.chat.android.randomChannel +import io.getstream.chat.android.randomMember +import io.getstream.chat.android.randomUser import io.getstream.chat.android.ui.R -import io.getstream.chat.android.ui.createMember -import io.getstream.chat.android.ui.createUser -import io.getstream.chat.android.ui.randomChannel import io.getstream.chat.android.uiutils.extension.getDisplayName import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Test @@ -29,9 +29,9 @@ internal class ChannelKtTest { @Test fun `given a channel has only one member it should have the name of the member`() { - val randomUser = createUser() - val member = createMember(user = randomUser) - val oneMemberChannel = randomChannel(members = listOf(member)) + val randomUser = randomUser() + val member = randomMember(user = randomUser) + val oneMemberChannel = randomChannel(name = "", members = listOf(member)) randomUser.name `should be equal to` oneMemberChannel.getDisplayName( mock(), diff --git a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/MessageEllipsizeTest.kt b/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/MessageEllipsizeTest.kt index 831d470ea2a..d20a5cec1fc 100644 --- a/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/MessageEllipsizeTest.kt +++ b/stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/utils/MessageEllipsizeTest.kt @@ -16,7 +16,7 @@ package io.getstream.chat.android.ui.utils -import io.getstream.chat.android.test.randomString +import io.getstream.chat.android.randomString import org.amshove.kluent.internal.assertEquals import org.junit.jupiter.api.Test