-
Notifications
You must be signed in to change notification settings - Fork 731
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
Changes room hierarchy endpoint to stable #5443
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3b0a565
Changes room hierarchy endpoint
ericdecanini bc3b8d0
Adds testing for fallback api
ericdecanini 0af6ae6
Adds logic for using stable and unstable hierarchy endpoints
ericdecanini e5299d7
Fixes legal comments
ericdecanini eb46067
Changes caught exception type to Throwable
ericdecanini 82b5fc9
Removes unused imports
ericdecanini 510206a
Adds changelog file
ericdecanini 0892525
Adds debug logs
ericdecanini 54828f7
Adds slash to v1 prefix path
ericdecanini 31f300c
Adds error print stack trace
ericdecanini fb374b7
Fixes wrong path parameter in getSpaceHierarchy
ericdecanini 63cd79d
Removes debug logs
ericdecanini 047e767
Adds coroutinesTest to matrix sdk gradle
ericdecanini bbc6e8b
Replaces caught Exception with HttpException
ericdecanini f76f73f
Refactors DefaultSpaceService querySpaceChildren
ericdecanini 2f706d6
Replaces children state event room id with space id
ericdecanini a891f59
Replaces lateinit var with passing params
ericdecanini a5af478
Renames mapToSpaceChildInfoList to mapSpaceChildren in DefaultSpaceSe…
ericdecanini 7226864
Improves code formatting in ResolveSpaceInfoTask
ericdecanini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adds stable room hierarchy endpoint with a fallback to the unstable one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...est/java/org/matrix/android/sdk/internal/session/space/DefaultResolveSpaceInfoTaskTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2021 The Matrix.org Foundation C.I.C. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 org.matrix.android.sdk.internal.session.space | ||
|
||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.runBlockingTest | ||
import okhttp3.ResponseBody.Companion.toResponseBody | ||
import org.amshove.kluent.shouldBeEqualTo | ||
import org.junit.Test | ||
import org.matrix.android.sdk.test.fakes.FakeGlobalErrorReceiver | ||
import org.matrix.android.sdk.test.fakes.FakeSpaceApi | ||
import org.matrix.android.sdk.test.fixtures.SpacesResponseFixture.aSpacesResponse | ||
import retrofit2.HttpException | ||
import retrofit2.Response | ||
|
||
@ExperimentalCoroutinesApi | ||
internal class DefaultResolveSpaceInfoTaskTest { | ||
|
||
private val spaceApi = FakeSpaceApi() | ||
private val globalErrorReceiver = FakeGlobalErrorReceiver() | ||
private val resolveSpaceInfoTask = DefaultResolveSpaceInfoTask(spaceApi.instance, globalErrorReceiver) | ||
|
||
@Test | ||
fun `given stable endpoint works, when execute, then return stable api data`() = runBlockingTest { | ||
spaceApi.givenStableEndpointReturns(response) | ||
|
||
val result = resolveSpaceInfoTask.execute(spaceApi.params) | ||
|
||
result shouldBeEqualTo response | ||
} | ||
|
||
@Test | ||
fun `given stable endpoint fails, when execute, then fallback to unstable endpoint`() = runBlockingTest { | ||
spaceApi.givenStableEndpointThrows(httpException) | ||
spaceApi.givenUnstableEndpointReturns(response) | ||
|
||
val result = resolveSpaceInfoTask.execute(spaceApi.params) | ||
|
||
result shouldBeEqualTo response | ||
} | ||
|
||
companion object { | ||
private val response = aSpacesResponse() | ||
private val httpException = HttpException(Response.error<SpacesResponse>(500, "".toResponseBody())) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/FakeSpaceApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2021 The Matrix.org Foundation C.I.C. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 org.matrix.android.sdk.test.fakes | ||
|
||
import io.mockk.coEvery | ||
import io.mockk.mockk | ||
import org.matrix.android.sdk.internal.session.space.SpaceApi | ||
import org.matrix.android.sdk.internal.session.space.SpacesResponse | ||
import org.matrix.android.sdk.test.fixtures.ResolveSpaceInfoTaskParamsFixture | ||
|
||
internal class FakeSpaceApi { | ||
|
||
val instance: SpaceApi = mockk() | ||
val params = ResolveSpaceInfoTaskParamsFixture.aResolveSpaceInfoTaskParams() | ||
|
||
fun givenStableEndpointReturns(response: SpacesResponse) { | ||
coEvery { instance.getSpaceHierarchy(params.spaceId, params.suggestedOnly, params.limit, params.maxDepth, params.from) } returns response | ||
} | ||
|
||
fun givenStableEndpointThrows(throwable: Throwable) { | ||
coEvery { instance.getSpaceHierarchy(params.spaceId, params.suggestedOnly, params.limit, params.maxDepth, params.from) } throws throwable | ||
} | ||
|
||
fun givenUnstableEndpointReturns(response: SpacesResponse) { | ||
coEvery { instance.getSpaceHierarchyUnstable(params.spaceId, params.suggestedOnly, params.limit, params.maxDepth, params.from) } returns response | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bmarty please pay more attention to this line. This is where
{children_state event}.roomId
was being used. I can only assume its intended use was to point to the space id? Please correct me if I'm wrong.I don't have a great understanding of spacesEdit: Spoke to @clokep to get more info on this. I believe this to be correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍