-
Notifications
You must be signed in to change notification settings - Fork 0
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
9ebbc6c
commit 76da7a9
Showing
10 changed files
with
119 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
plugins { | ||
alias(libs.plugins.starter.library.android) | ||
alias(libs.plugins.starter.library.kotlin) | ||
alias(libs.plugins.kotlin.serialization) | ||
} | ||
|
||
android { | ||
namespace "io.githhub.usefulness.licensee.android.core" | ||
} | ||
|
||
dependencies { | ||
implementation(libs.org.jetbrains.kotlinx.kotlinx.serialization.json) | ||
implementation(libs.org.jetbrains.kotlinx.kotlinx.serialization.json.okio) | ||
api(libs.kotlinx.serialization.json) | ||
implementation(libs.kotlinx.serialization.json.okio) | ||
api(libs.com.squareup.okio) | ||
|
||
testImplementation(libs.org.jetbrains.kotlin.kotlin.test.junit) | ||
testImplementation(libs.org.jetbrains.kotlinx.kotlinx.coroutines.test) | ||
} |
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
94 changes: 94 additions & 0 deletions
94
sample/core/src/test/kotlin/se/premex/gross/oss/LicenseParserTest.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,94 @@ | ||
package se.premex.gross.oss | ||
|
||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import okio.buffer | ||
import okio.source | ||
import se.premex.gross.core.LicenseParser | ||
import kotlin.test.Test | ||
|
||
private const val ARTIFACTS_SMALL = """[ | ||
{ | ||
"groupId": "androidx.activity", | ||
"artifactId": "activity", | ||
"version": "1.7.0", | ||
"name": "Activity", | ||
"spdxLicenses": [ | ||
{ | ||
"identifier": "Apache-2.0", | ||
"name": "Apache License 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
], | ||
"scm": { | ||
"url": "https://cs.android.com/androidx/platform/frameworks/support" | ||
} | ||
} | ||
]""" | ||
|
||
private const val ARTIFACTS_MEDIUM = """[ | ||
{ | ||
"groupId": "androidx.activity", | ||
"artifactId": "activity", | ||
"version": "1.7.0", | ||
"name": "Activity", | ||
"spdxLicenses": [ | ||
{ | ||
"identifier": "Apache-2.0", | ||
"name": "Apache License 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
], | ||
"scm": { | ||
"url": "https://cs.android.com/androidx/platform/frameworks/support" | ||
} | ||
}, | ||
{ | ||
"groupId": "androidx.activity", | ||
"artifactId": "activity-compose", | ||
"version": "1.7.0", | ||
"name": "Activity Compose", | ||
"spdxLicenses": [ | ||
{ | ||
"identifier": "Apache-2.0", | ||
"name": "Apache License 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
], | ||
"scm": { | ||
"url": "https://cs.android.com/androidx/platform/frameworks/support" | ||
} | ||
}, | ||
{ | ||
"groupId": "androidx.activity", | ||
"artifactId": "activity-ktx", | ||
"version": "1.7.0", | ||
"name": "Activity Kotlin Extensions", | ||
"spdxLicenses": [ | ||
{ | ||
"identifier": "Apache-2.0", | ||
"name": "Apache License 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
], | ||
"scm": { | ||
"url": "https://cs.android.com/androidx/platform/frameworks/support" | ||
} | ||
} | ||
]""" | ||
|
||
class LicenseParserTest { | ||
@Test | ||
@ExperimentalSerializationApi | ||
fun testSmall() = runTest { | ||
val licenseParser = object : LicenseParser {} | ||
licenseParser.decode(ARTIFACTS_SMALL.byteInputStream().source().buffer()) | ||
} | ||
|
||
@Test | ||
@ExperimentalSerializationApi | ||
fun testMedium() = runTest { | ||
val licenseParser = object : LicenseParser {} | ||
licenseParser.decode(ARTIFACTS_MEDIUM.byteInputStream().source().buffer()) | ||
} | ||
} |
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