Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests for old format parser in capabilities (WPB-12022) #3173

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import com.wire.kalium.mocks.responses.ClientResponseJson
import com.wire.kalium.mocks.responses.RegisterClientRequestJson
import com.wire.kalium.mocks.responses.RegisterTokenJson
import com.wire.kalium.mocks.responses.UpdateClientRequestJson
import com.wire.kalium.network.api.base.authenticated.client.ClientApi
import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO
import com.wire.kalium.network.api.authenticated.client.UpdateClientCapabilitiesRequest
import com.wire.kalium.network.api.base.authenticated.client.ClientApi
import com.wire.kalium.network.api.v0.authenticated.ClientApiV0
import com.wire.kalium.network.exceptions.KaliumException
import com.wire.kalium.network.utils.NetworkResponse
Expand Down Expand Up @@ -58,7 +58,26 @@ internal class ClientApiV0Test : ApiTest() {
val clientApi: ClientApi = ClientApiV0(networkClient)
val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData)
assertTrue(response.isSuccessful())
assertEquals(response.value, VALID_REGISTER_CLIENT_RESPONSE.serializableData)
assertEquals(VALID_REGISTER_CLIENT_RESPONSE.serializableData, response.value)
}

@Test
fun givenAValidRegisterClientRequest_whenCallingTheRegisterClientEndpointWithOldFormat_theRequestShouldBeConfiguredCorrectly() =
runTest {
val networkClient = mockAuthenticatedNetworkClient(
VALID_REGISTER_CLIENT_OLD_RESPONSE.rawJson,
statusCode = HttpStatusCode.Created,
assertion = {
assertPost()
assertJson()
assertNoQueryParams()
assertPathEqual(PATH_CLIENTS)
}
)
val clientApi: ClientApi = ClientApiV0(networkClient)
val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData)
assertTrue(response.isSuccessful())
assertEquals(VALID_REGISTER_CLIENT_OLD_RESPONSE.serializableData, response.value)
}

@Test
Expand Down Expand Up @@ -93,6 +112,7 @@ internal class ClientApiV0Test : ApiTest() {

assertTrue(response.isSuccessful())
}

@Test
fun givenAValidUpdateClientCapabilitiesRequest_whenCallingTheUpdateClientEndpoint_theRequestShouldBeConfiguredCorrectly() =
runTest {
Expand Down Expand Up @@ -172,6 +192,7 @@ internal class ClientApiV0Test : ApiTest() {
const val PATH_CLIENTS = "/clients"
val REGISTER_CLIENT_REQUEST = RegisterClientRequestJson.valid
val VALID_REGISTER_CLIENT_RESPONSE = ClientResponseJson.valid
val VALID_REGISTER_CLIENT_OLD_RESPONSE = ClientResponseJson.validCapabilitiesObject
val UPDATE_CLIENT_REQUEST = UpdateClientRequestJson.valid
val ERROR_RESPONSE = ErrorResponseJson.valid.serializableData
val VALID_PUSH_TOKEN_REQUEST = RegisterTokenJson.validPushTokenRequest
Expand Down
Loading