From bed6f58870335d03029d832ae3f7e8b232b573cd Mon Sep 17 00:00:00 2001 From: tomascayuelas Date: Fri, 1 Dec 2023 10:17:36 +0000 Subject: [PATCH] Apply spotless formatting --- .../functional/xef/evaluator/EitherOpsSpec.kt | 14 +- .../xef/evaluator/ItemSpecBuilderSpec.kt | 9 +- .../xef/evaluator/SuiteBuilderSpec.kt | 243 +++++++++--------- .../xef/evaluator/TestModelsSpec.kt | 2 +- 4 files changed, 137 insertions(+), 131 deletions(-) diff --git a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/EitherOpsSpec.kt b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/EitherOpsSpec.kt index f5f261b8b..55ea3df2f 100644 --- a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/EitherOpsSpec.kt +++ b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/EitherOpsSpec.kt @@ -12,11 +12,11 @@ import io.kotest.assertions.json.shouldEqualJson import io.kotest.common.runBlocking import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.next -import kotlinx.coroutines.test.runTest import kotlin.io.path.absolutePathString import kotlin.io.path.createTempDirectory import kotlin.io.path.listDirectoryEntries import kotlin.test.Test +import kotlinx.coroutines.test.runTest class EitherOpsSpec { private val validSuiteSpec = runBlocking { @@ -54,14 +54,14 @@ class EitherOpsSpec { fun shouldSerializeToJsonTheAccumulatedErrors() = runTest { val invalidJsonSuiteSpec = SuiteSpec(emptyString.next()) { - outputDescription { emptyString.next() } - outputDescription { emptyString.next() } + outputDescription { emptyString.next() } + outputDescription { emptyString.next() } - itemSpec(emptyString.next()) { - contextDescription { emptyString.next() } - outputResponse { emptyString.next() } + itemSpec(emptyString.next()) { + contextDescription { emptyString.next() } + outputResponse { emptyString.next() } + } } - } .toJson() val expectedStringJson = diff --git a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/ItemSpecBuilderSpec.kt b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/ItemSpecBuilderSpec.kt index e76e7429b..4c7a4e487 100644 --- a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/ItemSpecBuilderSpec.kt +++ b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/ItemSpecBuilderSpec.kt @@ -9,8 +9,8 @@ import com.xebia.functional.xef.evaluator.models.errors.ValidationError import io.kotest.assertions.arrow.core.shouldBeLeft import io.kotest.matchers.collections.shouldContainAll import io.kotest.matchers.shouldBe -import kotlinx.coroutines.test.runTest import kotlin.test.Test +import kotlinx.coroutines.test.runTest class ItemSpecBuilderSpec { @@ -160,11 +160,6 @@ class ItemSpecBuilderSpec { } invalidItemSpec shouldBeLeft - listOf( - EmptyItemSpecInput, - EmptyContextDescription, - EmptyOutputResponse, - EmptyOutputResponse - ) + listOf(EmptyItemSpecInput, EmptyContextDescription, EmptyOutputResponse, EmptyOutputResponse) } } diff --git a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/SuiteBuilderSpec.kt b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/SuiteBuilderSpec.kt index 0ab6770b3..0ec3e138f 100644 --- a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/SuiteBuilderSpec.kt +++ b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/SuiteBuilderSpec.kt @@ -1,12 +1,12 @@ package com.xebia.functional.xef.evaluator import com.xebia.functional.xef.evaluator.models.SuiteSpec -import com.xebia.functional.xef.evaluator.models.errors.MoreOutputsDescriptionThanItemsSpec -import com.xebia.functional.xef.evaluator.models.errors.LessOutputsDescriptionThanItemsSpec import com.xebia.functional.xef.evaluator.models.errors.EmptyItemSpecOutputResponse +import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecDescription import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecOutputDescription import com.xebia.functional.xef.evaluator.models.errors.InvalidNumberOfItemSpecOutputResponse -import com.xebia.functional.xef.evaluator.models.errors.EmptySuiteSpecDescription +import com.xebia.functional.xef.evaluator.models.errors.LessOutputsDescriptionThanItemsSpec +import com.xebia.functional.xef.evaluator.models.errors.MoreOutputsDescriptionThanItemsSpec import com.xebia.functional.xef.evaluator.models.errors.OutputsDescriptionNotProvided import com.xebia.functional.xef.evaluator.models.errors.ValidationError import com.xebia.functional.xef.evaluator.utils.Generators.emptyString @@ -15,28 +15,29 @@ import io.kotest.assertions.arrow.core.shouldBeLeft import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.next -import kotlinx.coroutines.test.runTest import kotlin.test.Test +import kotlinx.coroutines.test.runTest class SuiteBuilderSpec { @Test fun shouldBuildValidSuiteSpec() = runTest { SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } - outputDescription { simpleString.next() } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } - } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } - } - }.shouldBeRight() + outputDescription { simpleString.next() } + outputDescription { simpleString.next() } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } + } + .shouldBeRight() } @Test @@ -44,58 +45,62 @@ class SuiteBuilderSpec { val emptyDescription = emptyString.next() SuiteSpec(emptyDescription) { - outputDescription { simpleString.next() } + outputDescription { simpleString.next() } - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } } - }.shouldBeLeft() shouldBe listOf(EmptySuiteSpecDescription) + .shouldBeLeft() shouldBe listOf(EmptySuiteSpecDescription) } @Test fun shouldInvalidWithoutOutputDescriptionProvided() = runTest { SuiteSpec(simpleString.next()) { - // no output description provided ... - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } - } - }.shouldBeLeft() shouldBe listOf(OutputsDescriptionNotProvided) + // no output description provided ... + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } + } + .shouldBeLeft() shouldBe listOf(OutputsDescriptionNotProvided) } @Test fun shouldInvalidWithMoreOutputsDescriptionsThatItemsSpec() = runTest { SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } - outputDescription { simpleString.next() } + outputDescription { simpleString.next() } + outputDescription { simpleString.next() } - itemSpec("Please provide a movie title") { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } + itemSpec("Please provide a movie title") { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } } - }.shouldBeLeft() shouldBe listOf(MoreOutputsDescriptionThanItemsSpec) + .shouldBeLeft() shouldBe listOf(MoreOutputsDescriptionThanItemsSpec) } @Test fun shouldInvalidWithLessOutputsDescriptionThanItemsSpec() = runTest { SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } + outputDescription { simpleString.next() } - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } - } + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } } - }.shouldBeLeft() shouldBe listOf(LessOutputsDescriptionThanItemsSpec) + .shouldBeLeft() shouldBe listOf(LessOutputsDescriptionThanItemsSpec) } @Test @@ -103,71 +108,76 @@ class SuiteBuilderSpec { val emptyOutputDescription = emptyString.next() SuiteSpec(simpleString.next()) { - outputDescription { emptyOutputDescription } - outputDescription { emptyOutputDescription } - outputDescription { simpleString.next() } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } - }.shouldBeLeft() shouldBe listOf( - EmptySuiteSpecOutputDescription(0), - EmptySuiteSpecOutputDescription(1), - InvalidNumberOfItemSpecOutputResponse(0), - InvalidNumberOfItemSpecOutputResponse(1), - InvalidNumberOfItemSpecOutputResponse(2) - ) + outputDescription { emptyOutputDescription } + outputDescription { emptyOutputDescription } + outputDescription { simpleString.next() } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } + } + .shouldBeLeft() shouldBe + listOf( + EmptySuiteSpecOutputDescription(0), + EmptySuiteSpecOutputDescription(1), + InvalidNumberOfItemSpecOutputResponse(0), + InvalidNumberOfItemSpecOutputResponse(1), + InvalidNumberOfItemSpecOutputResponse(2) + ) } @Test fun shouldInvalidWithOneItemSpecWithoutOneOutPutResponse() = runTest { SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } - outputDescription { simpleString.next() } + outputDescription { simpleString.next() } + outputDescription { simpleString.next() } - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } } - }.shouldBeLeft() shouldBe listOf(InvalidNumberOfItemSpecOutputResponse(0)) + .shouldBeLeft() shouldBe listOf(InvalidNumberOfItemSpecOutputResponse(0)) } @Test fun shouldInvalidWithTwoItemsSpecWithoutOneOutputResponse() = runTest { SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } - outputDescription { simpleString.next() } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - } - }.shouldBeLeft() shouldBe listOf( - InvalidNumberOfItemSpecOutputResponse(0), - InvalidNumberOfItemSpecOutputResponse(1), - ) + outputDescription { simpleString.next() } + outputDescription { simpleString.next() } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + } + } + .shouldBeLeft() shouldBe + listOf( + InvalidNumberOfItemSpecOutputResponse(0), + InvalidNumberOfItemSpecOutputResponse(1), + ) } @Test @@ -175,20 +185,21 @@ class SuiteBuilderSpec { val emptyOutputResponse = emptyString.next() SuiteSpec(simpleString.next()) { - outputDescription { simpleString.next() } - outputDescription { simpleString.next() } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { simpleString.next() } - } - - itemSpec(simpleString.next()) { - contextDescription { simpleString.next() } - outputResponse { simpleString.next() } - outputResponse { emptyOutputResponse } - } - }.shouldBeLeft() shouldBe listOf(EmptyItemSpecOutputResponse(1)) + outputDescription { simpleString.next() } + outputDescription { simpleString.next() } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { simpleString.next() } + } + + itemSpec(simpleString.next()) { + contextDescription { simpleString.next() } + outputResponse { simpleString.next() } + outputResponse { emptyOutputResponse } + } + } + .shouldBeLeft() shouldBe listOf(EmptyItemSpecOutputResponse(1)) } } diff --git a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/TestModelsSpec.kt b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/TestModelsSpec.kt index fdf6a1791..e404b7a84 100644 --- a/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/TestModelsSpec.kt +++ b/evaluator/src/test/kotlin/com/xebia/functional/xef/evaluator/TestModelsSpec.kt @@ -11,8 +11,8 @@ import com.xebia.functional.xef.evaluator.utils.Generators.simpleString import io.kotest.assertions.arrow.core.shouldBeLeft import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.property.arbitrary.next -import kotlinx.coroutines.test.runTest import kotlin.test.Test +import kotlinx.coroutines.test.runTest class TestModelsSpec {