diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 025617d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: 2.1 - -orbs: - android: circleci/android@2.0.0 - gcp-cli: circleci/gcp-cli@2.2.0 - -jobs: - unit-test: - executor: - name: android/android-machine - resource-class: large - tag: 2021.10.1 - steps: - - checkout - - android/restore-gradle-cache - - android/restore-build-cache - - android/run-tests: - test-command: ./gradlew testDebug - - android/save-gradle-cache - - android/save-build-cache - - run: - name: Save test results - command: | - mkdir -p ~/test-results/junit/ - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; - when: always - - store_test_results: - path: ~/test-results - - store_artifacts: - path: ~/test-results/junit -workflows: - unittest-workflow: - jobs: - - unit-test \ No newline at end of file diff --git a/.github/workflows/gradle-dependency-submission.yml b/.github/workflows/gradle-dependency-submission.yml new file mode 100644 index 0000000..56f3a5c --- /dev/null +++ b/.github/workflows/gradle-dependency-submission.yml @@ -0,0 +1,25 @@ +name: Gradle Dependency Submission + +on: + push: + branches: [ "main" ] + +jobs: + dependency-submission: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@v4 diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml new file mode 100644 index 0000000..5a6f914 --- /dev/null +++ b/.github/workflows/gradle-test.yml @@ -0,0 +1,43 @@ +name: Gradle Build and Tests + +on: + push: + branches: [ "main" ] + pull_request: + +jobs: + build-and-test: + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + pull-requests: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Adding Google Services + env: + DATA: ${{ secrets.GOOGLE_SERVICES }} + run: echo $DATA | base64 -di > ./example/google-services.json + + - name: Build with Gradle Wrapper + run: ./gradlew build -x lint + + - name: Test with Gradle Wrapper + run: ./gradlew test + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: success() || failure() # always run even if the previous step fails + with: + report_paths: '**/build/test-results/test*/TEST-*.xml' diff --git a/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreRealTimeTests.kt b/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreRealTimeTests.kt index 46cb79f..8d7c73a 100644 --- a/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreRealTimeTests.kt +++ b/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreRealTimeTests.kt @@ -135,7 +135,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.NewNotification("NewNotification")) // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) storePage.edges.mapIndexed { index, edge -> store[index].id.shouldBe(edge.node.id) @@ -160,7 +160,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString())) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount) @@ -185,7 +185,7 @@ internal class NotificationStoreRealTimeTests { // THEN store[chosenIndex].readAt.shouldNotBeNull() - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount - 1) @@ -211,7 +211,7 @@ internal class NotificationStoreRealTimeTests { // THEN store[chosenIndex].readAt.shouldNotBeNull() store[chosenIndex].seenAt.shouldNotBeNull() - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount - 1) @@ -235,7 +235,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.ReadNotification("Not exists")) // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) storePage.edges.mapIndexed { index, edge -> @@ -262,7 +262,7 @@ internal class NotificationStoreRealTimeTests { // THEN store[chosenIndex].readAt.shouldBeNull() - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount + 1) @@ -288,7 +288,7 @@ internal class NotificationStoreRealTimeTests { // THEN store[chosenIndex].readAt.shouldBeNull() - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount) @@ -311,7 +311,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.UnreadNotification("Not exists")) // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) Unit } @@ -334,7 +334,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString())) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.totalCount.shouldBeExactly(initialCounter.totalCount - 1) store.unreadCount.shouldBeExactly(initialCounter.unreadCount - 1) store.forEach { notification -> @@ -359,7 +359,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString())) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.unseenCount.shouldBeExactly(initialCounter.unseenCount - 1) Unit } @@ -381,7 +381,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString())) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.unseenCount.shouldBeExactly(initialCounter.unseenCount) Unit } @@ -402,7 +402,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.DeleteNotification("Not exists")) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.totalCount.shouldBeExactly(initialCounter.totalCount) store.unreadCount.shouldBeExactly(initialCounter.unreadCount) store.unseenCount.shouldBeExactly(initialCounter.unseenCount) @@ -424,7 +424,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.ReadAllNotification) // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.forEach { notification -> notification.readAt.shouldNotBeNull() @@ -446,7 +446,7 @@ internal class NotificationStoreRealTimeTests { storeRealTime.processMessage(RealTimeEventMock.SeenAllNotification) // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.forEach { notification -> notification.seenAt.shouldNotBeNull() @@ -977,7 +977,7 @@ internal class NotificationStoreRealTimeTests { ) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize - 1) store.totalCount.shouldBeExactly(initialCounter.totalCount - 1) Unit diff --git a/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreTests.kt b/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreTests.kt index ab64d83..e4ad685 100644 --- a/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreTests.kt +++ b/sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreTests.kt @@ -125,7 +125,7 @@ internal class NotificationStoreTests { val notifications = store.fetch().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) notifications.size.shouldBeExactly(defaultEdgeArraySize) notifications.forEachIndexed { index, notification -> @@ -147,7 +147,7 @@ internal class NotificationStoreTests { store.fetch() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) storePage.edges.map { it.node.id }.shouldBe(store.notifications.map { it.id }) } @@ -170,7 +170,7 @@ internal class NotificationStoreTests { } // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(0) errorExpected.shouldNotBeNull() Unit @@ -190,7 +190,7 @@ internal class NotificationStoreTests { val notifications = store.refresh().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) notifications.size.shouldBeExactly(defaultEdgeArraySize) notifications.forEachIndexed { index, notification -> @@ -216,7 +216,7 @@ internal class NotificationStoreTests { } // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(0) errorExpected.shouldNotBeNull() Unit @@ -236,14 +236,14 @@ internal class NotificationStoreTests { store.fetch().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) // WHEN val notifications = store.fetch().getOrThrow() // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize * 2) notifications.size.shouldBeExactly(defaultEdgeArraySize) store.mapIndexed { index, notification -> @@ -265,14 +265,14 @@ internal class NotificationStoreTests { store.fetch().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) // WHEN val notifications = store.fetch().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) notifications.size.shouldBeExactly(0) Unit @@ -292,7 +292,7 @@ internal class NotificationStoreTests { store.refresh().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) storePage.edges.mapIndexed { index, edge -> store[index].id.shouldBe(edge.node.id) @@ -302,7 +302,7 @@ internal class NotificationStoreTests { store.refresh().getOrThrow() // THEN - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) storePage.edges.mapIndexed { index, edge -> store[index].id.shouldBe(edge.node.id) @@ -381,8 +381,8 @@ internal class NotificationStoreTests { store.delete(store[removeIndex]) // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } - coVerify(exactly = 1) { deleteNotificationInteractor.invoke(removedNotification.id, userQuery) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { deleteNotificationInteractor.invoke(removedNotification.id, userQuery) } } @Test @@ -411,8 +411,8 @@ internal class NotificationStoreTests { } // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } - coVerify(exactly = 1) { deleteNotificationInteractor.invoke(removedNotification.id, userQuery) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { deleteNotificationInteractor.invoke(removedNotification.id, userQuery) } errorExpected.shouldNotBeNull() Unit } @@ -640,8 +640,8 @@ internal class NotificationStoreTests { store.markAsRead(store[chosenIndex]).getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } - coVerify(exactly = 1) { actionNotificationInteractor.invoke(MARK_AS_READ, markReadNotification.id, userQuery) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { actionNotificationInteractor.invoke(MARK_AS_READ, markReadNotification.id, userQuery) } } @Test @@ -667,8 +667,8 @@ internal class NotificationStoreTests { } // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } - coVerify(exactly = 1) { actionNotificationInteractor.invoke(MARK_AS_READ, markReadNotification.id, userQuery) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { actionNotificationInteractor.invoke(MARK_AS_READ, markReadNotification.id, userQuery) } errorExpected.shouldNotBeNull() Unit } @@ -880,7 +880,7 @@ internal class NotificationStoreTests { store.markAsUnread(store[chosenIndex]).getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(MARK_AS_UNREAD, markReadNotification.id, userQuery) } } @@ -1000,7 +1000,7 @@ internal class NotificationStoreTests { store.archive(store[chosenIndex]).getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(ARCHIVE, markReadNotification.id, userQuery) } confirmVerified(actionNotificationInteractor) } @@ -1045,7 +1045,7 @@ internal class NotificationStoreTests { store.unarchive(store[chosenIndex]).getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(UNARCHIVE, markReadNotification.id, userQuery) } confirmVerified(actionNotificationInteractor) } @@ -1087,7 +1087,7 @@ internal class NotificationStoreTests { store.markAllNotificationAsRead().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(MARK_ALL_AS_READ, null, userQuery) } confirmVerified(actionNotificationInteractor) } @@ -1113,7 +1113,7 @@ internal class NotificationStoreTests { } // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(MARK_ALL_AS_READ, null, userQuery) } confirmVerified(actionNotificationInteractor) errorExpected.shouldNotBeNull() @@ -1218,7 +1218,7 @@ internal class NotificationStoreTests { store.markAllNotificationAsSeen().getOrThrow() // THEN - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } coVerify { actionNotificationInteractor.invoke(MARK_ALL_AS_SEEN, null, userQuery) } confirmVerified(actionNotificationInteractor) } @@ -1314,11 +1314,11 @@ internal class NotificationStoreTests { val sizeIndexes = indexes.size contentObserver.didInsertCounter.shouldBeExactly(1) contentObserver.didInsertSpy[0].indexes.shouldBe(indexes) - coVerify(exactly = 1) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize) store.fetch().getOrThrow() - coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) } + coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) } store.size.shouldBeExactly(defaultEdgeArraySize * 2) indexes = sizeIndexes.until(store.size).toList() contentObserver.didInsertCounter.shouldBeExactly(2)