Skip to content

Commit a035ee7

Browse files
committed
[ECO-5517] Added comprehensive unit tests for liveobjects Helpers
1 parent 523dfe4 commit a035ee7

4 files changed

Lines changed: 453 additions & 6 deletions

File tree

lib/src/main/java/io/ably/lib/realtime/ChannelBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ public Map<String, String> getParams() {
12871287

12881288
public ChannelMode[] getModes() {
12891289
if (modes == null) {
1290-
return null;
1290+
return new ChannelMode[0];
12911291
}
12921292
return modes.toArray(new ChannelMode[modes.size()]);
12931293
}

live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ internal fun LiveObjectsAdapter.throwIfUnpublishableState(channelName: String) {
138138
}
139139

140140
// Spec: RTO2
141-
internal fun LiveObjectsAdapter.throwIfMissingChannelMode(channelName: String, channelMode: ChannelMode) {
141+
private fun LiveObjectsAdapter.throwIfMissingChannelMode(channelName: String, channelMode: ChannelMode) {
142142
val channelModes = getChannelModes(channelName)
143143
if (channelModes == null || !channelModes.contains(channelMode)) {
144144
// Spec: RTO2a2, RTO2b2
145145
throw ablyException("\"${channelMode.name}\" channel mode must be set for this operation", ErrorCode.ChannelModeRequired)
146146
}
147147
}
148148

149-
internal fun LiveObjectsAdapter.throwIfInChannelState(channelName: String, channelStates: Array<ChannelState>) {
149+
private fun LiveObjectsAdapter.throwIfInChannelState(channelName: String, channelStates: Array<ChannelState>) {
150150
val currentState = getChannel(channelName).state
151151
if (currentState == null || channelStates.contains(currentState)) {
152152
throw ablyException("Channel is in invalid state: $currentState", ErrorCode.ChannelStateError)

live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ abstract class IntegrationTest {
2929
/**
3030
* Retrieves a realtime channel for the specified channel name and client ID
3131
* If a client with the given clientID does not exist, a new client is created using the provided options.
32-
* The channel is attached and ensured to be in the attached state before returning.
3332
*
3433
* @param channelName Name of the channel
3534
* @param clientId The ID of the client to use or create. Defaults to "client1".
36-
* @return The attached realtime channel.
37-
* @throws Exception If the channel fails to attach or the client fails to connect.
35+
* @return The realtime channel in the INITIALIZED state.
36+
* @throws Exception If the client fails to connect.
3837
*/
3938
internal suspend fun getRealtimeChannel(channelName: String, clientId: String = "client1"): Channel {
4039
val client = realtimeClients.getOrPut(clientId) {

0 commit comments

Comments
 (0)