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

chore: adr in code and junit5 parameterized tests (WPB-10396) #3288

Merged
merged 27 commits into from
Aug 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
994ed4f
doc: add adr
yamilmedina Aug 5, 2024
ed91888
doc: add lib param tests
yamilmedina Aug 5, 2024
550146a
Merge branch 'develop' into chore/adr-and-tests
yamilmedina Aug 5, 2024
516a7f5
chore: add param tests
yamilmedina Aug 5, 2024
b0c5def
chore: add param tests
yamilmedina Aug 5, 2024
6bcd8cf
chore: add param tests
yamilmedina Aug 5, 2024
19a7f70
Revert "chore: add param tests"
yamilmedina Aug 5, 2024
2be9995
chore: generate docs
yamilmedina Aug 6, 2024
dea2139
chore: generate docs
yamilmedina Aug 6, 2024
ce89d5a
chore: manual cherrypick
yamilmedina Aug 6, 2024
8a57160
chore:action
yamilmedina Aug 6, 2024
6c3c607
chore: adrstatus
yamilmedina Aug 6, 2024
e1c2654
chore: adrstatus, fix ref
yamilmedina Aug 6, 2024
9efcfed
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
5d99719
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
55621b4
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
0c617bd
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
7edaedb
chore: empty commit bump
yamilmedina Aug 6, 2024
9a347fb
chore: empty commit bump
yamilmedina Aug 6, 2024
bff9043
chore: empty commit bump
yamilmedina Aug 6, 2024
9632b4a
Merge branch 'develop' into chore/adr-and-tests
yamilmedina Aug 6, 2024
bd90e24
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
93be52e
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
8f23e70
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
92a0bda
chore: adrstatus, fix action
yamilmedina Aug 6, 2024
dfb29f6
Merge branch 'develop' into chore/adr-and-tests
yamilmedina Aug 9, 2024
58b4464
Merge branch 'develop' into chore/adr-and-tests
yamilmedina Aug 9, 2024
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
Prev Previous commit
Next Next commit
chore: add param tests
  • Loading branch information
yamilmedina committed Aug 5, 2024
commit 6bcd8cf302dda91ca8e277c5ad84db77915bbffb
75 changes: 22 additions & 53 deletions app/src/test/kotlin/com/wire/android/util/UriUtilTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,17 @@ package com.wire.android.util
import com.wire.android.string
import org.amshove.kluent.internal.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.EnumSource
import java.net.URI
import kotlin.random.Random

class UriUtilTest {
@Test
fun givenLink_whenTheLinkStartsWithHttps_thenReturnsTheSameLink() {
val input = "https://google.com"
val expected = "https://google.com"
val actual = normalizeLink(input)
assertEquals(expected, actual)
}

@Test
fun givenLink_whenTheLinkStartsWithHttp_thenReturnsTheSameLink() {
val input = "http://google.com"
val expected = "http://google.com"
val actual = normalizeLink(input)
assertEquals(expected, actual)
}

@Test
fun givenLink_whenTheLinkStartsWithMailTo_thenReturnsTheSameLink() {
val input = "mailto:alice@wire.com"
val expected = "mailto:alice@wire.com"
val actual = normalizeLink(input)
assertEquals(expected, actual)
}

@Test
fun givenLink_whenTheLinkIsWireDeepLink_thenReturnsTheSameLink() {
val input = "wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json"
val expected = "wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json"
val actual = normalizeLink(input)
assertEquals(expected, actual)
@ParameterizedTest
@EnumSource(TestParams::class)
fun `should map other urls to normalized accordingly`(params: TestParams) {
assertEquals(params.expected, normalizeLink(params.input), "Failed for input: <${params.input}>")
}

@Test
Expand All @@ -73,40 +50,32 @@ class UriUtilTest {
assertEquals(expected, actual)
}

@Test
fun givenLink_whenTheLinkIsValidWithoutSchema_thenReturnsTheLinkWithHttps() {
val input = "google.com"
val expected = "https://$input"
val actual = normalizeLink(input)
assertEquals(expected, actual)
}

@Test
fun givenEncodedLink_whenTheLinkIsValidWithSchema_thenReturnsTheSameLink() {
val input = "https://google.com/this+is+a+link+with+space"
val actual = normalizeLink(input)
assertEquals(input, actual)
}

@Test
fun givenLinkWithQueryParams_whenCallingFindParameterValue_thenReturnsParamValue() {
val parameterName = "wire_client"
val parameterValue = "value1"
val url = "https://example.com?play=value&$parameterName=$parameterValue"
val actual = URI(url).findParameterValue(parameterName)
assertEquals(parameterValue, actual)
}

@Test
fun givenLinkWithoutRequestedParam_whenCallingFindParameterValue_thenReturnsParamValue() {
val url = "https://example.com?play=value1"
val actual = URI(url).findParameterValue("wire_client")
assertEquals(null, actual)
}

@Test
fun givenLinkWithoutParams_whenCallingFindParameterValue_thenReturnsParamValue() {
val url = "https://example.com"
val actual = URI(url).findParameterValue("wire_client")
assertEquals(null, actual)
}

companion object {

enum class TestParams(val input: String, val expected: String) {
HTTPS_LINK("https://google.com", "https://google.com"),
HTTP_LINK("http://google.com", "http://google.com"),
MAIL_TO_LINK("mailto:alice@wire.com", "mailto:alice@wire.com"),
DEEP_LINK(
"wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json",
"wire://access/?config=https://nginz-https.elna.wire.link/deeplink.json"
),
VALID_WITHOUT_SCHEMA("google.com", "https://google.com"),
VALID_ENCODED_LINK("https://google.com/this+is+a+link+with+space", "https://google.com/this+is+a+link+with+space"),
}
}
}