From 6919320c4d98edc7335d65edff9e0b11a75c2123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:31:33 +0000 Subject: [PATCH] Partial updates for membership information (#267) --- .../consumer/objects/member/PNMember.kt | 7 ++-- .../objects/membership/PNChannelMembership.kt | 5 ++- .../objects/uuid/PNUUIDMetadataResult.kt | 2 +- .../pubsub/objects/PNObjectEventResult.kt | 5 ++- .../contract/membership/step/WhenSteps.kt | 24 ++++++------ .../objects_api/member/PNMembers.java | 4 +- .../objects_api/membership/PNMembership.java | 4 +- .../v2/callbacks/DelegatingEventListener.java | 4 +- .../callbacks/DelegatingEventListenerTest.kt | 2 +- .../consumer/objects/member/PNMember.kt | 18 +++++++-- .../objects/membership/PNChannelMembership.kt | 30 +++++++++++++- .../objects/uuid/PNUUIDMetadataResult.kt | 2 +- .../pubsub/objects/PNObjectEventResult.kt | 5 ++- .../membership/PNChannelMembershipTest.kt | 39 +++++++++++++++++++ .../pubnub/test/integration/MembersTest.kt | 10 ++--- .../test/integration/MembershipsTest.kt | 10 ++--- .../com/pubnub/test/integration/PushTest.kt | 12 ++++++ .../api/integration/ObjectsIntegrationTest.kt | 9 +++-- 18 files changed, 143 insertions(+), 49 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt index a6c889284..049e31a09 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt @@ -1,13 +1,14 @@ package com.pubnub.internal.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.utils.PatchValue data class PNMember( - val uuid: PNUUIDMetadata?, - val custom: Map? = null, + val uuid: PNUUIDMetadata, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val uuidId: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt index fd72a11d5..ea3e52fc1 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,13 +1,14 @@ package com.pubnub.internal.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.utils.PatchValue data class PNChannelMembership( val channel: PNChannelMetadata, - val custom: Map?, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val channelId: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt index 6f837e122..d743391e2 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt @@ -4,5 +4,5 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata data class PNUUIDMetadataResult( val status: Int, - val data: PNUUIDMetadata?, + val data: PNUUIDMetadata, ) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt index 398c848fa..860a9d5cc 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -7,6 +7,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PubSubResult +import com.pubnub.api.utils.PatchValue import com.pubnub.internal.utils.PolymorphicDeserializer import com.pubnub.internal.utils.UnwrapSingleField @@ -95,10 +96,10 @@ data class PNSetMembershipEvent( val channel: String, @JsonAdapter(UnwrapSingleField::class) val uuid: String, - val custom: Map?, + val custom: PatchValue?>?, val eTag: String, val updated: String, - val status: String?, + val status: PatchValue?, ) data class PNDeleteMembershipEvent( diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt index 21bb8e4c3..b9056a3a4 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt @@ -43,9 +43,9 @@ class WhenSteps( val channels = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } @@ -63,9 +63,9 @@ class WhenSteps( val channels = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } @@ -79,7 +79,7 @@ class WhenSteps( @When("I remove the membership") fun i_remove_the_membership() { - val channels = membershipState.memberships.map { it.channel!!.id } + val channels = membershipState.memberships.map { it.channel.id } world.pubnub.pubNubCore.removeMemberships( uuid = membershipState.uuid(), channels = channels, @@ -91,7 +91,7 @@ class WhenSteps( @When("I remove the membership for current user") fun i_remove_the_membership_for_current_user() { - val channels = membershipState.memberships.map { it.channel!!.id } + val channels = membershipState.memberships.map { it.channel.id } world.pubnub.pubNubCore.removeMemberships( channels = channels, ).sync().let { @@ -105,12 +105,12 @@ class WhenSteps( val channelsToSet = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } - val channelsToRemove = membershipState.membershipsToRemove.map { it.channel!!.id } + val channelsToRemove = membershipState.membershipsToRemove.map { it.channel.id } world.pubnub.pubNubCore.manageMemberships( channelsToSet = channelsToSet, channelsToRemove = channelsToRemove, diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java index 1504726fe..23403bb6a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java @@ -36,10 +36,10 @@ public static PNMembers from(@Nullable PNMember member) { } return new PNMembers() .setUuid(PNUUIDMetadata.from(member.getUuid())) - .setCustom(member.getCustom()) + .setCustom(member.getCustom() != null ? member.getCustom().getValue() : null) .setUpdated(member.getUpdated()) .setETag(member.getETag()) - .setStatus(member.getStatus()); + .setStatus(member.getStatus() != null ? member.getStatus().getValue() : null); } public static List from(Collection members) { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java index 6d4abefc3..0427f1a57 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java @@ -39,11 +39,11 @@ public static PNMembership from(@Nullable PNChannelMembership data) { } PNChannelMetadata metadata = PNChannelMetadata.from(data.getChannel()); PNMembership newData = new PNMembership(metadata); - newData.setCustom(data.getCustom()); + newData.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); // newData.setUuid(data.get) //TODO where to get this? does it even exist in server responses? newData.setUpdated(data.getUpdated()); newData.setETag(data.getETag()); - newData.setStatus(data.getStatus()); + newData.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); return newData; } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java index 38b707cb7..106615008 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java @@ -164,8 +164,8 @@ static PNMembershipResult getSetMembershipResult(@NotNull PNObjectEventResult ob new PNChannelMetadata(data.getChannel(), null) ); membership.setUuid(data.getUuid()); - membership.setCustom(data.getCustom()); - membership.setStatus(data.getStatus()); + membership.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); + membership.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); membership.setUpdated(data.getUpdated()); membership.setETag(data.getETag()); return new PNMembershipResult( diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt index 49563754f..36caea8b0 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt @@ -294,7 +294,7 @@ internal class DelegatingEventListenerTest { @Test fun getSetMembershipResult() { - val metadata = PNSetMembershipEvent(channel, uuid, custom, eTag, updated, status) + val metadata = PNSetMembershipEvent(channel, uuid, PatchValue.of(custom), eTag, updated, PatchValue.of(status)) val message = PNSetMembershipEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index bbbc6cf8c..8ba1650c4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -1,14 +1,15 @@ package com.pubnub.api.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.utils.PatchValue import com.pubnub.kmp.CustomObject data class PNMember( - val uuid: PNUUIDMetadata?, - val custom: Map? = null, + val uuid: PNUUIDMetadata, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue?, ) { data class Partial( val uuidId: String, @@ -17,4 +18,15 @@ data class PNMember( ) : MemberInput { override val uuid: String = uuidId } + + // let's not make this public for now, but keep the implementation around in case it's needed + private operator fun plus(update: PNMember): PNMember { + return PNMember( + uuid + update.uuid, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index 98284a856..c51aec9c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,14 +1,16 @@ package com.pubnub.api.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.utils.PatchValue import com.pubnub.kmp.CustomObject data class PNChannelMembership( val channel: PNChannelMetadata, - val custom: Map?, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val channelId: String, @@ -17,4 +19,28 @@ data class PNChannelMembership( ) : ChannelMembershipInput { override val channel: String = channelId } + + // let's not make this public for now, but keep the implementation around in case it's needed + private operator fun plus(update: PNChannelMembership): PNChannelMembership { + return PNChannelMembership( + channel + update.channel, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } + + /** + * Merge information from this `PNChannelMembership` with new data from `update`, returning a new `PNChannelMembership` instance. + */ + operator fun plus(update: PNSetMembershipEvent): PNChannelMembership { + return PNChannelMembership( + channel, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt index 0ab32b35c..7c67daf43 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt @@ -2,5 +2,5 @@ package com.pubnub.api.models.consumer.objects.uuid data class PNUUIDMetadataResult( val status: Int, - val data: PNUUIDMetadata?, + val data: PNUUIDMetadata, ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt index dab9b4cc2..94b46dcb2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -4,6 +4,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PubSubResult +import com.pubnub.api.utils.PatchValue data class PNObjectEventResult( private val result: BasePubSubResult, @@ -68,10 +69,10 @@ data class PNDeleteUUIDMetadataEventMessage( data class PNSetMembershipEvent( val channel: String, val uuid: String, - val custom: Map?, + val custom: PatchValue?>?, val eTag: String, val updated: String, - val status: String?, + val status: PatchValue?, ) data class PNDeleteMembershipEvent( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt new file mode 100644 index 000000000..e29593098 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt @@ -0,0 +1,39 @@ +package com.pubnub.api.models.consumer.objects.membership + +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.utils.PatchValue +import com.pubnub.test.randomString +import kotlin.test.Test +import kotlin.test.assertEquals + +class PNChannelMembershipTest { + @Test + fun plus() { + val originalMembership = PNChannelMembership( + PNChannelMetadata(randomString()), + custom = PatchValue.of(mapOf(randomString() to randomString())), + updated = randomString(), + eTag = randomString(), + status = null + ) + + val updateMembership = PNSetMembershipEvent( + originalMembership.channel.id, + randomString(), + custom = null, + updated = randomString(), + eTag = randomString(), + status = PatchValue.of(randomString()) + ) + val expectedMembership = originalMembership.copy( + updated = updateMembership.updated, + eTag = updateMembership.eTag, + status = updateMembership.status + ) + + val actualMembership = originalMembership + updateMembership + + assertEquals(expectedMembership, actualMembership) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt index 7012658c6..06f22a160 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt @@ -35,8 +35,8 @@ class MembersTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } - assertEquals(customData, pnChannelDetails.custom) + val pnChannelDetails = result.data.single { it.uuid.id == pubnub.configuration.userId.value } + assertEquals(customData, pnChannelDetails.custom?.value) } @Test @@ -50,8 +50,8 @@ class MembersTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } - assertEquals(status, pnChannelDetails.status) + val pnChannelDetails = result.data.single { it.uuid.id == pubnub.configuration.userId.value } + assertEquals(status, pnChannelDetails.status?.value) } @Test @@ -71,7 +71,7 @@ class MembersTest : BaseIntegrationTest() { yield() val result = pubnub.getMemberships(pubnub.configuration.userId.value, page = next).await() next = result.next - assertFalse { result.data.any { it.channel?.id == channel } } + assertFalse { result.data.any { it.channel.id == channel } } if (next == null || result.data.isEmpty()) { break } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt index 3f09676a7..f42fb4f2f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt @@ -36,9 +36,9 @@ class MembershipsTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.channel?.id == channel } - assertEquals(channel, pnChannelDetails.channel?.id) - assertEquals(customData, pnChannelDetails.custom) + val pnChannelDetails = result.data.single { it.channel.id == channel } + assertEquals(channel, pnChannelDetails.channel.id) + assertEquals(customData, pnChannelDetails.custom?.value) } @Test @@ -60,7 +60,7 @@ class MembershipsTest : BaseIntegrationTest() { message as PNSetMembershipEventMessage assertEquals(channel, message.data.channel) assertEquals(pubnub.configuration.userId.value, message.data.uuid) - assertEquals(customData, message.data.custom) + assertEquals(customData, message.data.custom?.value) } } @@ -79,7 +79,7 @@ class MembershipsTest : BaseIntegrationTest() { while (true) { val result = pubnub.getChannelMembers(channel, page = next).await() next = result.next - assertFalse { result.data.any { it.uuid?.id == pubnub.configuration.userId.value } } + assertFalse { result.data.any { it.uuid.id == pubnub.configuration.userId.value } } if (next == null || result.data.isEmpty()) { break } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt index a9d701f4f..b0b76f133 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt @@ -94,6 +94,10 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + val result = pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) .await() @@ -107,6 +111,10 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) .await().channels.isEmpty() @@ -127,6 +135,10 @@ class PushTest : BaseIntegrationTest() { deviceId, ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + assertEquals(emptyList(), pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await().channels) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index b0867fb02..0197ce6fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -12,6 +12,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.utils.PatchValue import com.pubnub.test.CommonUtils.randomValue import com.pubnub.test.subscribeToBlocking import org.hamcrest.MatcherAssert.assertThat @@ -296,7 +297,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNMember( uuidMetadata(id = otherTestUuid), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -304,7 +305,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNMember( uuidMetadata(id = testUuid), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -344,7 +345,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNChannelMembership( channelMetadata(id = channel), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -352,7 +353,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNChannelMembership( channelMetadata(id = otherChannel), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, )