-
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.
Oppdatert etter flytting av kotlin-clients
- Loading branch information
1 parent
247777d
commit 3b594a2
Showing
12 changed files
with
140 additions
and
227 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
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,77 +1,28 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
kotlin("plugin.serialization") | ||
id("org.jmailen.kotlinter") | ||
id("maven-publish") | ||
java | ||
} | ||
|
||
group = "no.nav.paw" | ||
|
||
tasks { | ||
withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
test { | ||
useJUnitPlatform() | ||
} | ||
} | ||
|
||
val jvmMajorVersion: String by project | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
dependencies { | ||
api(libs.kotlinx.serialization.json) | ||
|
||
withSourcesJar() | ||
} | ||
implementation(libs.ktor.client.contentNegotiation) | ||
implementation(libs.ktor.client.okhttp) | ||
implementation(libs.ktor.serialization.kotlinx.json) | ||
implementation(libs.ktor.client.logging) | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenNav("*") | ||
testImplementation(libs.bundles.testLibsWithUnitTesting) | ||
testImplementation(libs.ktor.client.mock) | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
from(components["java"]) | ||
} | ||
} | ||
repositories { | ||
mavenNav("paw-kotlin-clients") | ||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(jvmMajorVersion)) | ||
} | ||
} | ||
|
||
dependencies { | ||
val ktorVersion: String by project | ||
val mockkVersion: String by project | ||
val kotlinSerializationVersion: String by project | ||
val junitJupiterVersion: String by project | ||
val slf4jVersion: String by project | ||
|
||
api("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion") | ||
|
||
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") | ||
implementation("io.ktor:ktor-client-core:$ktorVersion") | ||
implementation("io.ktor:ktor-client-okhttp:$ktorVersion") | ||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") | ||
implementation("io.ktor:ktor-client-logging:$ktorVersion") | ||
|
||
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion") | ||
testImplementation("io.ktor:ktor-client-mock:$ktorVersion") | ||
testImplementation("io.mockk:mockk:$mockkVersion") | ||
testImplementation("org.slf4j:slf4j-simple:$slf4jVersion") | ||
} | ||
|
||
fun RepositoryHandler.mavenNav(repo: String): MavenArtifactRepository { | ||
val githubPassword: String by project | ||
|
||
return maven { | ||
setUrl("https://maven.pkg.github.com/navikt/$repo") | ||
credentials { | ||
username = "x-access-token" | ||
password = githubPassword | ||
} | ||
} | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} |
41 changes: 7 additions & 34 deletions
41
lib/aareg-client/src/test/kotlin/no/nav/paw/aareg/AaregClientTest.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 |
---|---|---|
@@ -1,48 +1,21 @@ | ||
package no.nav.paw.aareg | ||
|
||
import io.kotest.core.spec.style.FreeSpec | ||
import io.kotest.matchers.collections.shouldContain | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
class AaregClientTest { | ||
class AaregClientTest : FreeSpec({ | ||
|
||
/* | ||
API Description: | ||
https://navikt.github.io/aareg/tjenester/integrasjon/api/ | ||
*/ | ||
@Test | ||
fun `Returnerer gyldig objekt når alt er oK`() { | ||
"Returnerer gyldig objekt når alt er ok" { | ||
val response = runBlocking { | ||
mockAaregClient(MockResponse.arbeidsforhold) | ||
.hentArbeidsforhold("ident", "call-id") | ||
} | ||
assertTrue(response.any { it.arbeidsgiver.organisasjonsnummer == "896929119" }) | ||
|
||
response.map { it.arbeidsgiver.organisasjonsnummer } shouldContain "896929119" | ||
} | ||
// | ||
// @Test | ||
// fun test_OK_svar_Med_Uventet_JSON() { | ||
// val response = runBlocking { | ||
// mockAaregClient(MockResponse.error) | ||
// .hentArbeidsforhold("hei", "54-56 That's My Number") | ||
// } | ||
// val empty = emptyList<Arbeidsforhold>() | ||
// assertEquals(empty, response) | ||
// } | ||
// | ||
// @Test | ||
// fun test_Server_Error() { | ||
// val response = runBlocking { | ||
// mockAaregClient("blablabla", HttpStatusCode.InternalServerError) | ||
// .hentArbeidsforhold("hei", "123456") | ||
// } | ||
// val empty = emptyList<Arbeidsforhold>() | ||
// assertEquals(empty, response) | ||
// } | ||
// | ||
// @Test | ||
// fun realDeal() { | ||
// val client = AaregClient(url = "blah") { "tja" } | ||
// val response = runBlocking { client.hentArbeidsforhold("hei", "Number 2") } | ||
// assertEquals(emptyList<Arbeidsforhold>(), response) | ||
// } | ||
} | ||
}) |
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.