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

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

BestellungRestTest.kt

Source:BestellungRestTest.kt Github

copy

Full Screen

...22import com.acme.bestellung.entity.KundeId23import com.acme.bestellung.rest.BestellungGetController.Companion.API_PATH24import com.acme.bestellung.rest.BestellungGetController.Companion.ID_PATTERN25import com.jayway.jsonpath.JsonPath26import io.kotest.assertions.assertSoftly27import io.kotest.matchers.collections.beEmpty28import io.kotest.matchers.collections.shouldContainExactly29import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder30import io.kotest.matchers.collections.shouldHaveSize31import io.kotest.matchers.shouldBe32import io.kotest.matchers.shouldNot33import io.kotest.matchers.shouldNotBe34import io.kotest.matchers.string.beBlank35import io.kotest.matchers.string.shouldMatch36import kotlinx.coroutines.ExperimentalCoroutinesApi37import kotlinx.coroutines.test.runTest38import org.junit.jupiter.api.DisplayName39import org.junit.jupiter.api.Nested40import org.junit.jupiter.api.Tag41import org.junit.jupiter.api.Test42import org.junit.jupiter.api.condition.EnabledForJreRange43import org.junit.jupiter.api.condition.JRE.JAVA_1744import org.junit.jupiter.api.condition.JRE.JAVA_1845import org.junit.jupiter.params.ParameterizedTest46import org.junit.jupiter.params.provider.CsvSource47import org.junit.jupiter.params.provider.ValueSource48import org.springframework.beans.factory.getBean49import org.springframework.boot.test.context.SpringBootTest50import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT51import org.springframework.boot.web.server.LocalServerPort52import org.springframework.context.ApplicationContext53import org.springframework.hateoas.MediaTypes.HAL_JSON54import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer55import org.springframework.http.HttpStatus.CREATED56import org.springframework.http.HttpStatus.NOT_FOUND57import org.springframework.http.HttpStatus.OK58import org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY59import org.springframework.test.context.ActiveProfiles60import org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication61import org.springframework.web.reactive.function.client.WebClient62import org.springframework.web.reactive.function.client.awaitBodilessEntity63import org.springframework.web.reactive.function.client.awaitBody64import org.springframework.web.reactive.function.client.awaitEntity65import org.springframework.web.reactive.function.client.awaitExchange66import java.math.BigDecimal67import java.math.BigDecimal.TEN68@Tag("rest")69@DisplayName("REST-Schnittstelle fuer Bestellungen testen")70@SpringBootTest(webEnvironment = RANDOM_PORT)71@ActiveProfiles(DEV)72@EnabledForJreRange(min = JAVA_17, max = JAVA_18)73@Suppress("ClassName", "UseDataClass")74@ExperimentalCoroutinesApi75class BestellungRestTest(@LocalServerPort private val port: Int, ctx: ApplicationContext) {76 private val baseUrl = "$SCHEMA://$HOST:$port$API_PATH"77 private val client = WebClient.builder()78 .filter(basicAuthentication(USER_ADMIN, PASSWORD))79 .baseUrl(baseUrl)80 .build()81 init {82 ctx.getBean<BestellungGetController>() shouldNotBe null83 }...

Full Screen

Full Screen

io.github.nstdio.http.ext.test-conventions.gradle.kts

Source:io.github.nstdio.http.ext.test-conventions.gradle.kts Github

copy

Full Screen

...13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")17import org.gradle.api.tasks.testing.logging.TestExceptionFormat18import org.gradle.configurationcache.extensions.capitalized19import org.gradle.kotlin.dsl.invoke20import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform21import org.jetbrains.kotlin.gradle.tasks.KotlinCompile22import org.paukov.combinatorics3.Generator23import java.lang.Boolean24import kotlin.String25import kotlin.Suppress26import kotlin.to27plugins {28 `java-library`29 idea30 id("de.jjohannes.extra-java-module-info")31}32val isCI = System.getenv("CI").toBoolean()33java {34 sourceSets {35 create("spiTest") {36 val output = sourceSets.main.get().output37 compileClasspath += output38 runtimeClasspath += output39 }40 }41}42val sourceSetsSpiTest by sourceSets.named("spiTest")43val spiTestImplementation by configurations44idea.module {45 testSourceDirs.addAll(sourceSetsSpiTest.allSource.srcDirs)46}47mapOf(48 "spiTestImplementation" to "testImplementation",49 "spiTestRuntimeOnly" to "testRuntimeOnly",50).forEach { (t, u) ->51 configurations.getByName(t) { extendsFrom(configurations.getByName(u)) }52}53tasks.withType<Test> {54 useJUnitPlatform()55 reports {56 html.required.set(!isCI)57 }58 testLogging {59 events("skipped", "failed")60 exceptionFormat = TestExceptionFormat.FULL61 }62}63val junitVersion = "5.8.2"64val assertJVersion = "3.22.0"65val kotestAssertionsVersion = "5.2.3"66val mockitoVersion = "4.4.0"67val jsonPathAssertVersion = "2.7.0"68val slf4jVersion = "1.7.36"69val jacksonVersion = "2.13.2.2"70val brotli4JVersion = "1.7.1"71val brotliOrgVersion = "0.1.2"72val gsonVersion = "2.9.0"73val jsonLibs = mapOf(74 "jackson" to "com.fasterxml.jackson.core",75 "gson" to "gson-$gsonVersion"76)77val spiDeps = listOf(78 "org.brotli:dec:$brotliOrgVersion",79 "com.aayushatharva.brotli4j:brotli4j:$brotli4JVersion",80 "com.google.code.gson:gson:$gsonVersion",81 "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"82)83dependencies {84 spiDeps.forEach { compileOnly(it) }85 /** AssertJ & Friends */86 testImplementation("org.assertj:assertj-core:$assertJVersion")87 testImplementation("io.kotest:kotest-assertions-core:$kotestAssertionsVersion")88 testImplementation("io.kotest:kotest-property:$kotestAssertionsVersion")89 testImplementation("io.kotest:kotest-assertions-json:$kotestAssertionsVersion")90 /** Jupiter */91 testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")92 testImplementation("org.mockito:mockito-core:$mockitoVersion")93 testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")94 testImplementation("org.slf4j:slf4j-simple:$slf4jVersion")95 testImplementation("org.awaitility:awaitility-kotlin:4.2.0")96 testImplementation("com.squareup.okhttp3:mockwebserver3-junit5:5.0.0-alpha.6")97 testImplementation("nl.jqno.equalsverifier:equalsverifier:3.10")98 testImplementation("com.tngtech.archunit:archunit-junit5:0.23.1")99 spiDeps.forEach { spiTestImplementation(it) }100 spiTestImplementation("com.aayushatharva.brotli4j:native-${getArch()}:$brotli4JVersion")101}102Generator.subset(jsonLibs.keys)103 .simple()104 .stream()105 .forEach { it ->106 val postFix = it.joinToString("And") { it.capitalized() }107 val taskName = if (postFix.isEmpty()) "spiTest" else "spiTestWithout${postFix}"108 tasks.create<Test>(taskName) {109 description = "Run SPI tests"110 group = "verification"111 testClassesDirs = sourceSetsSpiTest.output.classesDirs112 classpath = sourceSetsSpiTest.runtimeClasspath113 doFirst {114 val toExclude = classpath.filter { file ->115 it?.any { file.absolutePath.contains(it) } ?: false116 }117 if (!toExclude.isEmpty) {118 logger.info("Excluding jars from classpath: ")119 toExclude.forEach {120 logger.info(" - ${it.name}")121 }122 }123 classpath -= toExclude124 }125 }126 }127tasks.create<Task>("spiMatrixTest") {128 description = "The aggregator task for all tests"129 group = "verification"130 dependsOn(tasks.filter { it.name.startsWith("spiTest") })131}132tasks.withType<KotlinCompile> {133 kotlinOptions {134 jvmTarget = JavaVersion.VERSION_11.toString()135 }136}137tasks.check {138 dependsOn("spiMatrixTest")139}140tasks.build {141 dependsOn("spiMatrixTest")142}...

Full Screen

Full Screen

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

KeyProviderTest.kt

Source:KeyProviderTest.kt Github

copy

Full Screen

1package no.nav.security.mock.oauth2.token2import com.nimbusds.jose.jwk.JWKSet3import com.nimbusds.jose.jwk.KeyUse4import com.nimbusds.jose.jwk.RSAKey5import io.kotest.assertions.asClue6import io.kotest.assertions.throwables.shouldThrow7import io.kotest.matchers.collections.shouldBeIn8import io.kotest.matchers.collections.shouldNotBeIn9import io.kotest.matchers.shouldBe10import no.nav.security.mock.oauth2.OAuth2Exception11import no.nav.security.mock.oauth2.token.KeyProvider.Companion.INITIAL_KEYS_FILE12import org.junit.jupiter.api.Test13import java.io.File14import java.security.KeyPairGenerator15import java.security.interfaces.ECPublicKey16import java.security.interfaces.RSAPrivateKey17import java.security.interfaces.RSAPublicKey18internal class KeyProviderTest {19 private val initialRSAKeysFile = File("src/main/resources$INITIAL_KEYS_FILE")20 private val initialECKeysFile = File("src/main/resources/mock-oauth2-server-keys-ec.json")21 @Test22 fun `signingKey should return a RSA key from initial keys file until deque is empty`() {23 val provider = KeyProvider()...

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

LangTest.kt

Source:LangTest.kt Github

copy

Full Screen

1package com.github.durun.nitron.test2import com.github.durun.nitron.core.config.AntlrParserConfig3import com.github.durun.nitron.core.config.LangConfig4import com.github.durun.nitron.core.config.loader.NitronConfigLoader5import com.github.durun.nitron.core.parser.antlr.ParserStore6import io.kotest.assertions.throwables.shouldNotThrowAny7import io.kotest.core.spec.style.FreeSpec8import io.kotest.core.spec.style.freeSpec9import io.kotest.inspectors.forAll10import io.kotest.matchers.collections.shouldBeIn11import io.kotest.matchers.collections.shouldContainAll12import io.kotest.matchers.collections.shouldHaveAtLeastSize13import io.kotest.matchers.paths.shouldBeReadable14import io.kotest.mpp.log15import java.nio.file.Path16import java.nio.file.Paths17import kotlin.io.path.toPath18class LangTest : FreeSpec({19 val configPath = Paths.get("config/nitron.json")20 NitronConfigLoader.load(configPath).langConfig21 .filter { (_, config) -> config.parserConfig is AntlrParserConfig }22 .forEach { (lang, config) -> include(langTestFactory(lang, config)) }23})24fun langTestFactory(lang: String, config: LangConfig) = freeSpec {25 "config for $lang (${config.fileName})" - {26 val parser = ParserStore.getOrNull(config.parserConfig)27 val parserConfig = config.parserConfig as AntlrParserConfig28 "grammar files exist" {...

Full Screen

Full Screen

InvoiceCreatedConsumerIT.kt

Source:InvoiceCreatedConsumerIT.kt Github

copy

Full Screen

1package br.com.ifood.empresas.erp.feature.invoice2import br.com.ifood.empresas.erp.BaseConsumerITTest3import br.com.ifood.empresas.erp.delivery.shared.Defaults4import io.kotest.assertions.json.shouldMatchJsonResource5import io.kotest.matchers.ints.shouldBeExactly6import io.kotest.matchers.shouldBe7import io.kotest.matchers.shouldNotBe8import java.util.UUID9import java.util.concurrent.TimeUnit10import org.awaitility.kotlin.await11import org.awaitility.kotlin.untilAsserted12class InvoiceCreatedConsumerIT : BaseConsumerITTest() {13 companion object {14 const val INVOICE_CREATED_ASSET_EVENT_SAMPLE_1 = "invoice_created_1"15 const val DEFAULT_LOCK_KEY =16 "${Defaults.INVOICE_CREATED_EVENT}_2bb77c6e-53b4-11ec-bf63-0242ac130002_a96f0e6d-177e-4b66-9052-477a30a16054"17 }18 init {19 feature("A message processor for invoice created event") {20 val invoiceCreatedQueue = getQueueProperties().invoiceCreatedErpFacade.queueUrl21 // ignoring test22 xscenario("Should not send request when lock is already set") {23 clearCacheKeysByPrefix("${Defaults.INVOICE_CREATED_EVENT}_*")24 setLockForKey(DEFAULT_LOCK_KEY)25 setInvoiceDescriptionRolloutFlagTo(true)26 addGroupToRollout(UUID.fromString("063d9bc0-2242-4b76-aafa-60b7f3de72c8"))27 sendToQueue(28 invoiceCreatedQueue,29 INVOICE_CREATED_ASSET_EVENT_SAMPLE_130 )31 await.atMost(10, TimeUnit.SECONDS) untilAsserted {32 val createInvoiceRequest = mockWebServer.takeRequest()33 createInvoiceRequest.path shouldNotBe "/IFBTITRECEBER"34 }35 await.atMost(10, TimeUnit.SECONDS) untilAsserted {...

Full Screen

Full Screen

OverlayTextElementTest.kt

Source:OverlayTextElementTest.kt Github

copy

Full Screen

1package fr.delphes.bot.overlay2import io.kotest.assertions.json.shouldEqualJson3import io.kotest.matchers.shouldBe4import kotlinx.serialization.decodeFromString5import kotlinx.serialization.encodeToString6import kotlinx.serialization.json.Json7import org.junit.jupiter.api.Test8internal class OverlayTextElementSerializationTest {9 private val serializer = Json {10 ignoreUnknownKeys = true11 isLenient = false12 encodeDefaults = true13 coerceInputValues = true14 }15 @Test16 internal fun deserialize() {17 serializer.decodeFromString<OverlayElement>(...

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 keys

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful