-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f54dad4
commit ca2a00a
Showing
12 changed files
with
273 additions
and
11 deletions.
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
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
58 changes: 58 additions & 0 deletions
58
forgerock-core/src/test/java/org/forgerock/android/auth/ExtensionTest.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,58 @@ | ||
package org.forgerock.android.auth | ||
|
||
import junit.framework.TestCase.assertEquals | ||
import junit.framework.TestCase.assertFalse | ||
import junit.framework.TestCase.assertTrue | ||
import org.junit.Test | ||
|
||
class ExtensionTest { | ||
@Test | ||
fun testLongDateToString() { | ||
val longTimeStamp: Long = 1672947404167 // 20230105 13:36:44 | ||
val actualResult = longTimeStamp.convertToTime().split(" ") | ||
assertEquals(actualResult[0], "20230105") | ||
assertTrue(actualResult[1].isNotEmpty()) | ||
} | ||
|
||
@Test | ||
fun testLongDateToStringWithDifferentPattern() { | ||
val longTimeStamp: Long = 1672947404167 | ||
val actualResult = longTimeStamp.convertToTime("yyyyMMdd") | ||
val expectedResult = "20230105" | ||
assertEquals(actualResult, expectedResult) | ||
} | ||
|
||
@Test | ||
fun testPoorManTernary() { | ||
val list = listOf(1, 2, 3) | ||
val case1 = (list.contains(1) then true) ?: false | ||
assertTrue(case1) | ||
val case2 = (list.contains(5) then true) ?: false | ||
assertFalse(case2) | ||
} | ||
|
||
@Test | ||
fun testIsAbsoluteUrl() { | ||
val url = "https://www.example.com" | ||
assertTrue(url.isAbsoluteUrl()) | ||
} | ||
|
||
@Test | ||
fun testOnlyScheme() { | ||
val url = "https://" // Invalid URL | ||
assertFalse(url.isAbsoluteUrl()) | ||
} | ||
|
||
@Test | ||
fun testIsNotAbsoluteUrlWithoutScheme() { | ||
val url = "www.example.com" | ||
assertFalse(url.isAbsoluteUrl()) | ||
} | ||
|
||
@Test | ||
fun testIsNotAbsoluteUrlWithInvalidUrl() { | ||
val url = "/as/revoke" | ||
assertFalse(url.isAbsoluteUrl()) | ||
} | ||
|
||
} |
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
Oops, something went wrong.