How to use test method of io.kotest.assertions.json.resources class

Best Kotest code snippet using io.kotest.assertions.json.resources.test

JsonSerializeVerifiableCredentialTest.kt

Source:JsonSerializeVerifiableCredentialTest.kt Github

copy

Full Screen

1package id.walt.services.data2import com.beust.klaxon.Klaxon3import id.walt.vclib.credentials.Europass4import id.walt.vclib.credentials.PermanentResidentCard5import id.walt.vclib.credentials.VerifiableAttestation6import id.walt.vclib.model.*7import io.kotest.assertions.fail8import io.kotest.assertions.json.shouldEqualJson9import io.kotest.core.spec.style.AnnotationSpec10import io.kotest.matchers.shouldBe11import java.io.File12import java.time.LocalDateTime13class JsonSerializeVerifiableCredentialTest : AnnotationSpec() {14    val VC_PATH = "src/test/resources/verifiable-credentials"15    val format = Klaxon()16    @Test17    fun vcTemplatesTest() {18        File("templates/").walkTopDown()19            .filter { it.toString().endsWith(".json") }20            .forEach {21                println("serializing: $it")22                val input = File(it.toURI()).readText().replace("\\s".toRegex(), "")23                val vc = input.toCredential()24                when (vc) {25                    is Europass -> println("\t => Europass serialized")26                    is PermanentResidentCard -> {27                        println("\t => PermanentResidentCard serialized")28                        val enc = Klaxon().toJsonString(vc)29                        input shouldEqualJson enc30                    }31                    is VerifiableAttestation -> {32                        println("\t => EbsiVerifiableAttestation serialized")33                        val enc = Klaxon().toJsonString(vc)34                        input shouldEqualJson enc35                    }36                    else -> {37                        fail("VC type not supported")38                    }39                }40            }41    }42    @Test43    fun serializeEbsiVerifiableAuthorization() {44        val va = File("$VC_PATH/vc-ebsi-verifiable-authorisation.json").readText()45        val vc = va.toCredential()46    }47    @Test48    fun serializeSignedVc() {49        val signedEuropassStr = File("$VC_PATH/vc-europass-signed.json").readText()50        println(signedEuropassStr)51        val vc = signedEuropassStr.toCredential()52    }53    // TODO: remove / replace functions below as they are using the old data model54    @Test55    fun vcSerialization() {56        val input = File("templates/vc-template-default.json").readText().replace("\\s".toRegex(), "")57        val vc = Klaxon().parse<VerifiableCredential>(input)58        println(vc)59        val enc = Klaxon().toJsonString(vc)60        println(enc)61        input shouldEqualJson enc62    }63    @Test64    fun vcConstructTest() {65        val proof =66            Proof(67                type = "EidasSeal2019",68                created = LocalDateTime.now().withNano(0).toString(),69                creator = "did:creator",70                proofPurpose = "assertionMethod",71                verificationMethod = "EidasCertificate2019",//VerificationMethodCert("EidasCertificate2019", "1088321447"),72                jws = "BD21J4fdlnBvBA+y6D...fnC8Y="73            )74        val vc = VerifiableAttestation(75            context = listOf(76                "https://www.w3.org/2018/credentials/v1",77                "https://essif.europa.eu/schemas/v-a/2020/v1",78                "https://essif.europa.eu/schemas/eidas/2020/v1"79            ),80            id = "education#higherEducation#3fea53a4-0432-4910-ac9c-69ah8da3c37f",81            issuer = "did:ebsi:2757945549477fc571663bee12042873fe555b674bd294a3",82            issued = "2019-06-22T14:11:44Z",83            validFrom = "2019-06-22T14:11:44Z",84            credentialSubject = VerifiableAttestation.VerifiableAttestationSubject(85                id = "id123"86            ),87            credentialStatus = CredentialStatus(88                id = "https://essif.europa.eu/status/identity#verifiableID#1dee355d-0432-4910-ac9c-70d89e8d674e",89                type = "CredentialStatusList2020"90            ),91            credentialSchema = CredentialSchema(92                id = "https://essif.europa.eu/tsr-vid/verifiableid1.json",93                type = "JsonSchemaValidator2018"94            ),95            evidence = listOf(96                VerifiableAttestation.Evidence(97                    id = "https://essif.europa.eu/tsr-va/evidence/f2aeec97-fc0d-42bf-8ca7-0548192d5678",98                    type = listOf("DocumentVerification"),99                    verifier = "did:ebsi:2962fb784df61baa267c8132497539f8c674b37c1244a7a",100                    evidenceDocument = "Passport",101                    subjectPresence = "Physical",102                    documentPresence = "Physical"103                )104            ),105            proof = Proof(106                type = "EidasSeal2021",107                created = "2019-06-22T14:11:44Z",108                proofPurpose = "assertionMethod",109                verificationMethod = "did:ebsi:2757945549477fc571663bee12042873fe555b674bd294a3#2368332668",110                jws = "HG21J4fdlnBvBA+y6D...amP7O="...

Full Screen

Full Screen

TestHelpers.kt

Source:TestHelpers.kt Github

copy

Full Screen

1package io.bkbn.kompendium.core.fixtures2import io.bkbn.kompendium.core.Kompendium3import io.bkbn.kompendium.oas.serialization.KompendiumSerializersModule4import io.kotest.assertions.json.shouldEqualJson5import io.kotest.assertions.ktor.shouldHaveStatus6import io.kotest.matchers.shouldBe7import io.kotest.matchers.shouldNotBe8import io.ktor.application.Application9import io.ktor.application.install10import io.ktor.features.ContentNegotiation11import io.ktor.gson.gson12import io.ktor.http.HttpMethod13import io.ktor.http.HttpStatusCode14import io.ktor.serialization.json15import io.ktor.server.testing.TestApplicationEngine16import io.ktor.server.testing.createTestEnvironment17import io.ktor.server.testing.handleRequest18import io.ktor.server.testing.withApplication19import kotlinx.serialization.json.Json20import java.io.File21object TestHelpers {22  private const val OPEN_API_ENDPOINT = "/openapi.json"23  const val DEFAULT_TEST_ENDPOINT = "/test"24  fun getFileSnapshot(fileName: String): String {25    val snapshotPath = "src/test/resources"26    val file = File("$snapshotPath/$fileName")27    return file.readText()28  }29  /**30   * Performs the baseline expected tests on an OpenAPI result.  Confirms that the endpoint31   * exists as expected, and that the content matches the expected blob found in the specified file32   * @param snapshotName The snapshot file to retrieve from the resources folder33   */34  fun TestApplicationEngine.compareOpenAPISpec(snapshotName: String) {35    // act36    handleRequest(HttpMethod.Get, OPEN_API_ENDPOINT).apply {37      // assert38      response shouldHaveStatus HttpStatusCode.OK39      response.content shouldNotBe null40      response.content!! shouldEqualJson getFileSnapshot(snapshotName)41    }42  }43  /**44   * This will take a provided JSON snapshot file, retrieve it from the resource folder,45   * and build a test ktor server to compare the expected output with the output found in the default46   * OpenAPI json endpoint.  By default, this will run the same test with Gson, Kotlinx, and Jackson serializers47   * @param snapshotName The snapshot file to retrieve from the resources folder48   * @param moduleFunction Initializer for the application to allow tests to pass the required Ktor modules49   */50  fun openApiTestAllSerializers(snapshotName: String, moduleFunction: Application.() -> Unit) {51    openApiTestAllSerializers(snapshotName, moduleFunction) {}52  }53  fun openApiTestAllSerializers(54    snapshotName: String, moduleFunction: Application.() -> Unit,55    kompendiumConfigurer: Kompendium.Configuration.() -> Unit56  ) {57    openApiTest(snapshotName, SupportedSerializer.KOTLINX, moduleFunction, kompendiumConfigurer)58    openApiTest(snapshotName, SupportedSerializer.JACKSON, moduleFunction, kompendiumConfigurer)59    openApiTest(snapshotName, SupportedSerializer.GSON, moduleFunction, kompendiumConfigurer)60  }61  private fun openApiTest(62    snapshotName: String,63    serializer: SupportedSerializer,64    moduleFunction: Application.() -> Unit,65    kompendiumConfigurer: Kompendium.Configuration.() -> Unit66  ) {67    withApplication(createTestEnvironment()) {68      moduleFunction(application.apply {69        kompendium(kompendiumConfigurer)70        docs()71        when (serializer) {72          SupportedSerializer.KOTLINX -> {73            install(ContentNegotiation) {74              json(Json {75                encodeDefaults = true76                explicitNulls = false77                serializersModule = KompendiumSerializersModule.module78              })79            }80          }81          SupportedSerializer.GSON -> {82            install(ContentNegotiation) {83              gson()84            }85          }86          SupportedSerializer.JACKSON -> {87            jacksonConfigModule()88          }89        }90      })91      compareOpenAPISpec(snapshotName)92    }93  }94  /**95   * This allows us to easily confirm that an API endpoints functionality is not impacted by notarization.96   * @param httpMethod The HTTP operation that we wish to perform97   * @param endpoint The relative endpoint we wish to hit98   * @param expectedResponse The expected response content of the operation99   * @param expectedStatusCode The expected status code of the operation100   */101  fun apiFunctionalityTest(102    expectedResponse: String?,103    endpoint: String = DEFAULT_TEST_ENDPOINT,104    httpMethod: HttpMethod = HttpMethod.Get,105    expectedStatusCode: HttpStatusCode = HttpStatusCode.OK,106    moduleFunction: Application.() -> Unit107  ) {108    withApplication(createTestEnvironment()) {109      moduleFunction(application.apply {110        kompendium()111        docs()112        jacksonConfigModule()113      })114      when (expectedResponse) {115        null -> testWithNoResponse(httpMethod, endpoint, expectedStatusCode)116        else -> testWithResponse(httpMethod, expectedResponse, endpoint, expectedStatusCode)117      }118    }119  }120  private fun TestApplicationEngine.testWithResponse(121    httpMethod: HttpMethod,122    expectedResponse: String,123    endpoint: String,124    expectedStatusCode: HttpStatusCode,125  ) {126    handleRequest(httpMethod, endpoint).apply {127      // assert128      response shouldHaveStatus expectedStatusCode129      response.content shouldNotBe null130      response.content shouldBe expectedResponse131    }132  }133  private fun TestApplicationEngine.testWithNoResponse(134    httpMethod: HttpMethod,135    endpoint: String,136    expectedStatusCode: HttpStatusCode,137  ) {138    handleRequest(httpMethod, endpoint).apply {139      // assert140      response shouldHaveStatus expectedStatusCode141      response.content shouldBe null142    }143  }144}...

Full Screen

Full Screen

VersionFileTest.kt

Source:VersionFileTest.kt Github

copy

Full Screen

1package no.elhub.tools.autorelease.project2import io.kotest.assertions.assertSoftly3import io.kotest.core.spec.style.DescribeSpec4import io.kotest.inspectors.forExactly5import io.kotest.matchers.collections.shouldContain6import io.kotest.matchers.shouldBe7import no.elhub.tools.autorelease.extensions.delete8import no.elhub.tools.autorelease.io.MavenPomReader.getProjectParentVersion9import no.elhub.tools.autorelease.io.MavenPomReader.getProjectVersion10import java.nio.file.Paths11import kotlin.io.path.ExperimentalPathApi12import kotlin.io.path.readLines13@OptIn(ExperimentalPathApi::class)14class VersionFileTest : DescribeSpec({15    afterSpec {16        // Clean up the test files17        Paths.get("build/resources/test/galaxy.yml").delete()18        Paths.get("build/resources/test/gradle.properties").delete()19        Paths.get("build/resources/test/pom.xml").delete()20        Paths.get("build/resources/test/package.json").delete()21        Paths.get("build/resources/test/multi-module-maven").delete()22    }23    describe("A galaxy.yml file to which VersionFile has been applied") {24        val project = ProjectType.ANSIBLE25        VersionFile.setVersion(26            Paths.get("build/resources/test/galaxy.yml"),27            project,28            String.format(project.versionFormat, "1.2.3")29        )30        it("should have its version set to 1.2.3") {31            val testFile = Paths.get("build/resources/test/galaxy.yml")32            val lines = testFile.readLines()33            lines shouldContain "version: 1.2.3"34        }35    }36    describe("A gradle.properties file to which VersionFile has been applied") {37        val project = ProjectType.GRADLE38        VersionFile.setVersion(39            Paths.get("build/resources/test/gradle.properties"),40            project,41            String.format(project.versionFormat, "1.2.3")42        )43        it("should have its version set to 1.2.3") {44            val testFile = Paths.get("build/resources/test/gradle.properties")45            val lines = testFile.readLines()46            lines shouldContain "version=1.2.3"47        }48    }49    describe("A pom.xml file to which VersionFile has been applied") {50        val project = ProjectType.MAVEN51        context("a single-module project") {52            VersionFile.setVersion(53                Paths.get("build/resources/test/pom.xml"),54                project,55                String.format(project.versionFormat, "1.2.3")56            )57            it("should have exactly one <version/> tag with the value set to 1.2.3") {58                val testFile = Paths.get("build/resources/test/pom.xml")59                testFile.readLines().forExactly(1) { it.trim() shouldBe "<version>1.2.3</version>" }60            }61        }62        context("a multi-module project") {63            VersionFile.setVersion(64                Paths.get("build/resources/test/multi-module-maven/pom.xml"),65                project,66                String.format(project.versionFormat, "1.2.3")67            )68            it("parent pom should have exactly one <version/> tag with the value set to 1.2.3") {69                val testFile = Paths.get("build/resources/test/multi-module-maven/pom.xml")70                testFile.readLines().forExactly(1) { it.trim() shouldBe "<version>1.2.3</version>" }71            }72            it("a <parent/> tag in the parent pom should not be affected") {73                val testFile = Paths.get("build/resources/test/multi-module-maven/pom.xml")74                getProjectParentVersion(testFile).textContent shouldBe "0.1.0-SNAPSHOT"75            }76            listOf("moduleA", "moduleB", "moduleC").forEach { sub ->77                it("$sub pom should have exactly one <version/> under <parent/> tag with the value set to 1.2.3") {78                    val testFile = Paths.get("build/resources/test/multi-module-maven/$sub/pom.xml")79                    getProjectParentVersion(testFile).textContent shouldBe "1.2.3"80                }81                if (sub == "moduleA") {82                    listOf("moduleAA", "moduleAB").forEach { subSub ->83                        it("$subSub pom should have exactly one <version/> under <parent/> tag with the value set to 1.2.3") {84                            val testFile = Paths.get("build/resources/test/multi-module-maven/$sub/$subSub/pom.xml")85                            getProjectParentVersion(testFile).textContent shouldBe "1.2.3"86                        }87                    }88                }89            }90            it("unregistered module's pom.xml should not be affected") {91                val testFile = Paths.get("build/resources/test/multi-module-maven/not-a-module/pom.xml")92                assertSoftly {93                    getProjectVersion(testFile)?.textContent shouldBe "0.1.0-SNAPSHOT"94                    getProjectParentVersion(testFile).textContent shouldBe "0.1.0-SNAPSHOT"95                }96            }97        }98    }99    describe("A package.json file to which VersionFile has been applied") {100        val project = ProjectType.NPM101        VersionFile.setVersion(102            Paths.get("build/resources/test/package.json"),103            project,104            String.format(project.versionFormat, "1.2.3")105        )106        it("should be have its version set to 1.2.3") {107            val testFile = Paths.get("build/resources/test/package.json")108            val lines = testFile.readLines()109            lines.any { it.contains("\"version\": \"1.2.3\"") } shouldBe true110        }111    }112})...

Full Screen

Full Screen

ConfigureBaseDependenciesAction.kt

Source:ConfigureBaseDependenciesAction.kt Github

copy

Full Screen

...41					when (requested.group) {42						"io.github.microutils"             -> useExtraVersion("microutils-logging")43						"org.slf4j"                        -> useExtraVersion("slf4j")44						"ch.qos.logback"                   -> useExtraVersion("logback")45						"io.kotest"                        -> useExtraVersion("kotest")46						"io.mockk"                         -> useExtraVersion("mockk")47						"io.github.serpro69"               -> useExtraVersion("kotlin-faker")48						"commons-codec"                    -> useExtraVersion("commons-codec")49						"io.ktor"                          -> useExtraVersion("ktor")50						"org.koin"                         -> useExtraVersion("koin")51						"org.kodein.di"                    -> useExtraVersion("kodein-di")52						"org.jetbrains.kotlin"             -> useExtraVersion("kotlin")53						"org.jetbrains.exposed"            -> useExtraVersion("exposed")54						"org.jetbrains.kotlinx"            -> when {55							requested.name.startsWith("kotlinx-coroutines")    -> useExtraVersion("kotlinx-coroutines")56							requested.name.startsWith("kotlinx-serialization") -> useExtraVersion("kotlinx-serialization")57							requested.name.startsWith("kotlinx-html")          -> useExtraVersion("kotlinx-html")58							requested.name.startsWith("kotlinx-datetime")      -> useExtraVersion("kotlinx-datetime")59						}60						"org.webjars"                      -> when (requested.name) {61							"swagger-ui" -> useExtraVersion("webjars-swagger")62						}63						"com.fasterxml.jackson"            -> useExtraVersion("jackson")64						"com.fasterxml.jackson.core"       -> useExtraVersion("jackson")65						"com.fasterxml.jackson.datatype"   -> useExtraVersion("jackson")66						"com.fasterxml.jackson.module"     -> useExtraVersion("jackson")67						"com.fasterxml.jackson.dataformat" -> useExtraVersion("jackson")68					}69				}70			}71		}72	}73	private fun configureDependencies(target: Project): Unit = target.run {74		dependencies {75			"implementation"("org.jetbrains.kotlinx:kotlinx-datetime")76			"testImplementation"("ch.qos.logback:logback-classic")77			"testImplementation"("io.kotest:kotest-runner-junit5")78			"testImplementation"("io.kotest:kotest-extensions-junit5")79			"testImplementation"("io.kotest:kotest-property")80			"testImplementation"("io.kotest:kotest-assertions-core")81			"testImplementation"("io.kotest:kotest-assertions-kotlinx-time")82			"testImplementation"("io.kotest:kotest-assertions-json")83			"testImplementation"("io.github.serpro69:kotlin-faker")84			"testImplementation"("io.mockk:mockk")85		}86	}87}...

Full Screen

Full Screen

build.gradle.kts

Source:build.gradle.kts Github

copy

Full Screen

...3    kotlin("jvm") version "1.6.10"4    kotlin("plugin.serialization") version "1.5.30"5    id("com.github.johnrengelman.shadow") version "7.1.2"6    id("com.github.ben-manes.versions") version "0.41.0"7    id("com.adarshr.test-logger") version "3.1.0"8    id("org.jlleitschuh.gradle.ktlint") version "10.2.1"9}10group = "pt.pedro"11application {12    @Suppress("Deprecation")13    mainClassName = "ApplicationKt"14}15repositories {16    mavenCentral()17    maven("https://jitpack.io")18}19val logbackVersion = "1.2.1"20val hopliteVersion = "1.4.16"21val ktorVersion = "1.6.3"22val exposedVersion = "0.37.3"23val h2Version = "2.1.210"24val postgresVersion = "42.3.1"25val flywayVersion = "8.4.2"26val kotestVersion = "5.1.0"27val kotestAssertionsKtorVersion = "1.0.3"28val mockkVersion = "1.12.2"29dependencies {30    implementation(kotlin("stdlib"))31    implementation("io.ktor:ktor-server-netty:$ktorVersion")32    implementation("ch.qos.logback:logback-classic:$logbackVersion")33    implementation("io.ktor:ktor-server-core:$ktorVersion")34    implementation("io.ktor:ktor-server-host-common:$ktorVersion")35    implementation("io.ktor:ktor-serialization:$ktorVersion")36    implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")37    implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")38    implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")39    implementation("com.h2database:h2:$h2Version")40    implementation("org.postgresql:postgresql:$postgresVersion")41    implementation("com.zaxxer:HikariCP:5.0.1")42    implementation("com.sksamuel.hoplite:hoplite-core:$hopliteVersion")43    implementation("com.sksamuel.hoplite:hoplite-hocon:$hopliteVersion")44    implementation("org.flywaydb:flyway-core:$flywayVersion")45    /* Tests */46    testImplementation("io.ktor:ktor-server-tests:$ktorVersion")47    testImplementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion") // for kotest framework48    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") // for kotest core jvm assertions49    testImplementation("io.kotest:kotest-assertions-json:$kotestVersion") // for kotest json assertions50    testImplementation("io.kotest:kotest-property-jvm:$kotestVersion") // for kotest property test51    testImplementation("io.kotest.extensions:kotest-assertions-ktor:$kotestAssertionsKtorVersion")52    testImplementation("io.mockk:mockk:$mockkVersion")53}54sourceSets {55    create("testIntegration") {56        withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {57            kotlin.srcDir("src/testIntegration/kotlin")58            resources.srcDir("src/testIntegration/resources")59            compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]60            runtimeClasspath += output + compileClasspath + sourceSets["test"].runtimeClasspath61        }62    }63}64tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {65    kotlinOptions {66        jvmTarget = "11"67    }68}69tasks.withType<Test> {70    useJUnitPlatform()71}72task<Test>("testIntegration") {73    description = "Runs the integration tests"74    group = "verification"75    testClassesDirs = sourceSets["testIntegration"].output.classesDirs76    classpath = sourceSets["testIntegration"].runtimeClasspath77}78tasks.check {79    dependsOn("testIntegration")80}81ktlint {82    disabledRules.set(setOf("no-wildcard-imports"))83    coloredOutput.set(true)84    filter {85        exclude("**/generated/**")86        exclude("**/build/**")87        include("**/kotlin/**")88    }89}90tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {91    mergeServiceFiles()92}...

Full Screen

Full Screen

KeyCommandTest.kt

Source:KeyCommandTest.kt Github

copy

Full Screen

...5//ANDROID PORT6import id.walt.servicematrix.utils.AndroidUtils7//ANDROID PORT8import id.walt.services.key.KeyService9import id.walt.test.RESOURCES_PATH10import io.kotest.assertions.throwables.shouldThrow11import io.kotest.core.spec.style.StringSpec12import io.kotest.matchers.string.shouldContain13//ANDROID PORT14import java.io.File15import java.io.FileInputStream16//ANDROID PORT17class KeyCommandTest : StringSpec({18    //ANDROID PORT19    AndroidUtils.setAndroidDataDir(System.getProperty("user.dir"))20    ServiceMatrix(FileInputStream(File("$RESOURCES_PATH/service-matrix.properties")))21    //ANDROID PORT22    "key gen --help" {23        val e = shouldThrow<PrintHelpMessage> {24            GenKeyCommand().parse(listOf("--help"))25        }26        val message = e.command.getFormattedHelp()27        message shouldContain "-a, --algorithm [Ed25519|Secp256k1]"28    }29    "key gen Ed25519" {30        GenKeyCommand().parse(listOf("-a", "Ed25519"))31    }32    "key gen Secp256k1" {33        GenKeyCommand().parse(listOf("-a", "Secp256k1"))34    }35    "key export Secp256k1" {36        val key = KeyService.getService().generate(KeyAlgorithm.ECDSA_Secp256k1)37        ExportKeyCommand().parse(listOf(key.id))38    }39    "key export Ed25519" {40        val key = KeyService.getService().generate(KeyAlgorithm.EdDSA_Ed25519)41        ExportKeyCommand().parse(listOf(key.id))42    }43    "key import Ed25519 priv key JWK" {44        ImportKeyCommand().parse(listOf("src/test/resources/cli/privKeyEd25519Jwk.json"))45        KeyService.getService().delete("45674a4ac169f7f4716804393d20480138a")46    }47    "key import Ed25519 pub key JWK" {48        ImportKeyCommand().parse(listOf("src/test/resources/cli/pubKeyEd25519Jwk.json"))49        KeyService.getService().delete("12374a4ac169f7f4716804393d20480138a")50    }51// Import in PEM format currently not supported52//    "key import Ed25519 priv key PEM" {53//        ImportKeyCommand().parse(listOf("src/test/resources/cli/privKeyEd25519Pem.txt", "src/test/resources/cli/pubKeyEd25519Pem.txt"))54//    }55//56//    "key import Ed25519 pub key PEM" {57//        ImportKeyCommand().parse(listOf("src/test/resources/cli/pubKeyEd25519Pem.txt"))58//    }59})...

Full Screen

Full Screen

GitHubMetricConverterSpec.kt

Source:GitHubMetricConverterSpec.kt Github

copy

Full Screen

1package sandbox.explorer.logic2import arrow.core.flatMap3import arrow.fx.fix4import io.kotest.assertions.arrow.either.shouldBeRight5import io.kotest.core.listeners.TestListener6import io.kotest.core.spec.style.StringSpec7import io.kotest.matchers.shouldBe8import java.io.File9import org.jetbrains.exposed.sql.StdOutSqlLogger10import org.jetbrains.exposed.sql.addLogger11import org.jetbrains.exposed.sql.transactions.transaction12import sandbox.explorer.DbSetupListener13import sandbox.explorer.Factories14import sandbox.explorer.GitHubUserInfo15import sandbox.explorer.Person16class GitHubMetricConverterSpec : StringSpec() {17    override fun listeners(): List<TestListener> = listOf(DbSetupListener)18    init {19        "converts the JSON data to GitHubMetric and persists it in the database" {20            val userInfoData: String = File("./resources/github-user-info.json").readText(Charsets.UTF_8)21            val gitHubUserInfo = GitHubUserInfo.deserializeFromJson2(userInfoData).value().fix().unsafeRunSync()...

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1val json = """{"a":1,"b":2}"""2json.shouldMatchJson("""{"a":1,"b":2}""")3json.shouldMatchJson("""{"b":2,"a":1}""")4json.shouldMatchJson("""{"a":2,"b":1}""", false)5json.shouldMatchJson("""{"b":1,"a":2}""", false)6json.shouldMatchJson("""{"a":1}""")7json.shouldMatchJson("""{"a":1,"b":2,"c":3}""")8json.shouldMatchJson("""{"a":1,"b":2,"c":3}""", false)9json.shouldMatchJson("""{"a":1,"b":2,"c":3}""", true)10val json = """{"a":1,"b":2}"""11json.shouldMatchJson("""{"a":1,"b":2}""")12json.shouldMatchJson("""{"b":2,"a":1}""")13json.shouldMatchJson("""{"a":2,"b":1}""", false)14json.shouldMatchJson("""{"b":1,"a":2}""", false)15json.shouldMatchJson("""{"a":1}""")16json.shouldMatchJson("""{"a":1,"b":2,"c":3}""")17json.shouldMatchJson("""{"a":1,"b":2,"c":3}""", false)18json.shouldMatchJson("""{"a":1,"b":2,"c":3}""", true)19val json = """{"a":1,"b":2}"""20json.shouldMatchJson("""{"a":1,"b":2}""")21json.shouldMatchJson("""{"b":2,"a":1}""")22json.shouldMatchJson("""{"a":2,"b":1}""", false)23json.shouldMatchJson("""{"b":1,"a":2}""", false)24json.shouldMatchJson("""{"a":1}""")25json.shouldMatchJson("""{"a":1,"b":2,"c":3}""")26json.shouldMatchJson("""{"a":1,"b":2,"c":3}""", false)27json.shouldMatchJson("""{"a":1,"

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1    fun `should return 200 with json response`() {2        withTestApplication({ module(testing = true) }) {3            handleRequest(HttpMethod.Get, "/").apply {4                assertEquals(HttpStatusCode.OK, response.status())5                response.content.shouldMatchJson(getResource("test.json"))6            }7        }8    }9}10fun main() {11    println("Hello, world!")12}

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected2val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected3val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected4val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected5val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected6val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected7val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected8val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected9val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected10val json = """{"a":"b"}""" .trimIndent() val expected = """{"a":"b"}""" .trimIndent() json shouldMatchJson expected

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1fun  `test json` () {2val  actual =  """{ "key" : "value" }"""3val  expected =  """{ "key" : "value" }"""4}5fun  `test json` () {6val  actual =  """{ "key" : "value" }"""7val  expected =  """{ "key" : "value" }"""8}9fun  `test json` () {10val  actual =  """{ "key" : "value" }"""11val  expected =  """{ "key" : "value" }"""12}13fun  `test json` () {14val  actual =  """{ "key" : "value" }"""15val  expected =  """{ "key" : "value" }"""16}17fun  `test json` () {18val  actual =  """{ "key" : "value" }"""19val  expected =  """{ "key" : "value" }"""20}21fun  `test json` () {22val  actual =  """{ "key" : "value" }"""23val  expected =  """{ "key" : "value" }"""24}25fun  `test json` () {26val  actual =  """{ "key" : "value" }"""27val  expected =  """{ "key" : "value" }"""28}29fun  `test json` () {

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1    fun `test json`() {2        val json = Json {3        }4        val expected = json.decodeFromString<JsonObject>(File("src/test/resources/expected.json").readText())5        val actual = json.decodeFromString<JsonObject>(File("src/test/resources/actual.json").readText())6    }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in resources

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful