Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit f5cda5e

Browse files
committed
release 6.0.0-alpha-1
1 parent eede465 commit f5cda5e

File tree

12 files changed

+39
-90
lines changed

12 files changed

+39
-90
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
```groovy
2323
// Typical microservices setup (Web API + DB + MQ) testing:
24-
testImplementation "io.github.adven27:exam-ms:6.0.0-bet-9"
24+
testImplementation "io.github.adven27:exam-ms:6.0.0-alpha-1"
2525
2626
//same as:
27-
//testImplementation "io.github.adven27:exam-ws:6.0.0-bet-9"
28-
//testImplementation "io.github.adven27:exam-db:6.0.0-bet-9"
29-
//testImplementation "io.github.adven27:exam-mq:6.0.0-bet-9"
27+
//testImplementation "io.github.adven27:exam-ws:6.0.0-alpha-1"
28+
//testImplementation "io.github.adven27:exam-db:6.0.0-alpha-1"
29+
//testImplementation "io.github.adven27:exam-mq:6.0.0-alpha-1"
3030
3131
// UI testing
32-
testImplementation "io.github.adven27:exam-ui:6.0.0-bet-9"
32+
testImplementation "io.github.adven27:exam-ui:6.0.0-alpha-1"
3333
```
3434
### 2) Use
3535

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
ext.exposed_version = '0.37.3'
55
ext.restAssured_version = '4.5.0'
66
ext.klogging_version = '2.1.21'
7-
ext.libVersion = '6.0.0-beta-9'
7+
ext.libVersion = '6.0.0-alpha-1'
88
repositories {
99
mavenCentral()
1010
}

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/Content.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ interface ContentVerifier {
141141
companion object : KLogging()
142142
}
143143

144-
open class XmlVerifier(private val nodeMatcher: NodeMatcher) : ContentVerifier.Default("xml") {
144+
open class XmlVerifier(protected val nodeMatcher: NodeMatcher) : ContentVerifier.Default("xml") {
145145

146146
@JvmOverloads
147147
constructor(configureNodeMatcher: (NodeMatcher) -> NodeMatcher = { it }) :
@@ -164,16 +164,15 @@ open class XmlVerifier(private val nodeMatcher: NodeMatcher) : ContentVerifier.D
164164
}
165165

166166
@Suppress("TooGenericExceptionCaught")
167-
open class JsonVerifier(private val configuration: Configuration) : ContentVerifier.Default("json") {
167+
open class JsonVerifier(protected val configuration: Configuration) : ContentVerifier.Default("json") {
168168

169169
@JvmOverloads
170170
constructor(configure: (Configuration) -> Configuration = { it }) : this(configure(ExamExtension.DEFAULT_JSON_UNIT_CFG))
171171

172172
override fun assertThat(expected: String, actual: String) {
173173
validate(actual)
174174
try {
175-
// set tolerance because of https://github.com/lukas-krecan/JsonUnit/issues/468
176-
JsonAssert.assertJsonEquals(expected, actual, configuration.withTolerance(0.0))
175+
JsonAssert.assertJsonEquals(expected, actual, configuration)
177176
} catch (ae: AssertionError) {
178177
throw ae
179178
} catch (e: Exception) {

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/ExamExtension.kt

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,6 @@ class ExamExtension constructor(private vararg var plugins: ExamPlugin) : Concor
7070
return this
7171
}
7272

73-
@Suppress("unused")
74-
fun withContentVerifiers(addContentVerifiers: Map<String, ContentVerifier>): ExamExtension {
75-
CONTENT_VERIFIERS += addContentVerifiers
76-
return this
77-
}
78-
79-
@Suppress("unused")
80-
fun withContentResolvers(addContentResolvers: Map<String, ContentResolver>): ExamExtension {
81-
CONTENT_RESOLVERS += addContentResolvers
82-
return this
83-
}
84-
85-
@Suppress("unused")
86-
fun withContentPrinters(addContentPrinters: Map<String, ContentPrinter>): ExamExtension {
87-
CONTENT_PRINTERS += addContentPrinters
88-
return this
89-
}
90-
9173
/**
9274
* All examples but failed will be collapsed
9375
*/
@@ -212,31 +194,6 @@ class ExamExtension constructor(private vararg var plugins: ExamPlugin) : Concor
212194
"Provide it via ExamExtension(...).withContentTypeConfigs(...) method."
213195
)
214196

215-
private val CONTENT_VERIFIERS: MutableMap<String, ContentVerifier> = mutableMapOf(
216-
"json" to JsonVerifier(),
217-
"xml" to XmlVerifier(),
218-
"text" to ContentVerifier.Default("text"),
219-
)
220-
221-
@JvmStatic
222-
fun contentVerifier(type: String): ContentVerifier = CONTENT_VERIFIERS[type]
223-
?: throw IllegalStateException(
224-
"Content verifier for type '$type' not found. " +
225-
"Provide it via ExamExtension(...).withContentVerifiers(...) method."
226-
)
227-
228-
private val CONTENT_RESOLVERS: MutableMap<String, ContentResolver> = mutableMapOf(
229-
"json" to JsonResolver(),
230-
"xml" to XmlResolver(),
231-
"text" to JsonResolver(),
232-
)
233-
234-
private val CONTENT_PRINTERS: MutableMap<String, ContentPrinter> = mutableMapOf(
235-
"json" to JsonPrinter(),
236-
"xml" to XmlPrinter(),
237-
"text" to ContentPrinter.AsIs(),
238-
)
239-
240197
@JvmStatic
241198
fun prettyXml(text: String) = text.prettyXml()
242199

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/commands/ExamCommand.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ import org.awaitility.core.ConditionFactory
1919
import org.concordion.api.AbstractCommand
2020
import org.concordion.api.Command
2121
import org.concordion.api.CommandCall
22-
import org.concordion.api.Element
2322
import org.concordion.api.Evaluator
2423
import org.concordion.api.Fixture
2524
import org.concordion.api.ResultRecorder
2625
import org.concordion.api.listener.ExecuteEvent
2726
import org.concordion.api.listener.ExecuteListener
2827
import org.concordion.internal.CatchAllExpectationChecker.normalize
2928
import org.concordion.internal.command.AssertEqualsCommand
30-
import org.concordion.internal.util.Announcer
3129
import java.util.concurrent.TimeUnit.MILLISECONDS
3230
import java.util.concurrent.TimeUnit.SECONDS
3331

@@ -55,7 +53,7 @@ open class ExamCommand(
5553
name: String,
5654
override val tag: String
5755
) : BeforeParseExamCommand, BaseExamCommand(name) {
58-
private val listeners = Announcer.to(ExecuteListener::class.java)
56+
private val listener = ExecuteListener {}
5957

6058
override fun execute(
6159
commandCall: CommandCall,
@@ -64,11 +62,8 @@ open class ExamCommand(
6462
fixture: Fixture
6563
) {
6664
commandCall.children.processSequentially(evaluator, resultRecorder, fixture)
67-
announceExecuteCompleted(commandCall.element)
65+
listener.executeCompleted(ExecuteEvent(commandCall.element))
6866
}
69-
70-
private fun announceExecuteCompleted(element: Element) =
71-
listeners.announce().executeCompleted(ExecuteEvent(element))
7267
}
7368

7469
open class ExamAssertEqualsCommand(

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/handlebars/matchers/MatcherHelpers.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.github.jknack.handlebars.Options
55
import io.github.adven27.concordion.extensions.exam.core.handlebars.ExamHelper
66
import io.github.adven27.concordion.extensions.exam.core.handlebars.HB_RESULT
77
import io.github.adven27.concordion.extensions.exam.core.utils.DateWithin.Companion.PARAMS_SEPARATOR
8+
import io.github.adven27.concordion.extensions.exam.core.utils.asString
89
import org.concordion.api.Evaluator
910
import java.util.regex.Pattern
1011

@@ -165,7 +166,7 @@ enum class MatcherHelpers(
165166
expected = "\${json-unit.matches:after}2000-01-31T23:59:59.000"
166167
) {
167168
override fun invoke(context: Any?, options: Options): Any =
168-
"\${${placeholderType(options.context)}-unit.matches:$name}$context"
169+
"\${${placeholderType(options.context)}-unit.matches:$name}${context!!.asString()}"
169170
},
170171
before(
171172
example = "{{before '2000-01-31T23:59:59.000'}}",

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/json/DefaultObjectMapperProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ open class DefaultObjectMapperProvider : Jackson2ObjectMapperProvider {
1414
configure(WRITE_BIGDECIMAL_AS_PLAIN, true)
1515
}
1616
private val lenientMapper: ObjectMapper = ObjectMapper().apply {
17-
configure(ALLOW_UNQUOTED_FIELD_NAMES, true)
17+
configure(USE_BIG_DECIMAL_FOR_FLOATS, true)
18+
configure(WRITE_BIGDECIMAL_AS_PLAIN, true)
1819
configure(ALLOW_UNQUOTED_FIELD_NAMES, true)
1920
configure(ALLOW_COMMENTS, true)
2021
configure(ALLOW_SINGLE_QUOTES, true)

exam-core/src/main/java/io/github/adven27/concordion/extensions/exam/core/utils/DateMatchers.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,8 @@ fun date(item: Any, pattern: String? = null): ZonedDateTime = when (item) {
163163
is Date -> item.toZonedDateTime()
164164
else -> item.toString().parseDate(pattern).toZonedDateTime()
165165
}
166+
167+
fun Any.asString(): String = when (this) {
168+
is Date -> toZonedDateTime().toString()
169+
else -> toString()
170+
}

exam-db/src/main/java/io/github/adven27/concordion/extensions/exam/db/commands/DataSetCommands.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ import org.concordion.api.Fixture
2020
import org.concordion.api.Result
2121
import org.concordion.api.Result.FAILURE
2222
import org.concordion.api.ResultRecorder
23-
import org.concordion.api.listener.AssertEqualsListener
2423
import org.concordion.api.listener.AssertFailureEvent
2524
import org.concordion.api.listener.AssertSuccessEvent
26-
import org.concordion.internal.util.Announcer
2725
import org.dbunit.assertion.DbComparisonFailure
2826
import org.dbunit.assertion.Difference
2927
import org.dbunit.dataset.ITable
@@ -87,11 +85,7 @@ class DataSetExecuteCommand(
8785
@Suppress("TooManyFunctions")
8886
class DataSetVerifyCommand(name: String, tag: String, val dbTester: DbTester, var valuePrinter: DbPlugin.ValuePrinter) :
8987
ExamCommand(name, tag) {
90-
private val listeners = Announcer.to(AssertEqualsListener::class.java)
91-
92-
init {
93-
listeners.addListener(DbResultRenderer())
94-
}
88+
private val listener = DbResultRenderer()
9589

9690
override fun verify(
9791
commandCall: CommandCall,
@@ -213,13 +207,13 @@ class DataSetVerifyCommand(name: String, tag: String, val dbTester: DbTester, va
213207

214208
private fun failure(resultRecorder: ResultRecorder, html: Html, actual: Any?, expected: String): Html {
215209
resultRecorder.record(FAILURE)
216-
listeners.announce().failureReported(AssertFailureEvent(html.el, expected, actual))
210+
listener.failureReported(AssertFailureEvent(html.el, expected, actual))
217211
return html
218212
}
219213

220214
private fun success(resultRecorder: ResultRecorder, html: Html): Html {
221215
resultRecorder.record(Result.SUCCESS)
222-
listeners.announce().successReported(AssertSuccessEvent(html.el))
216+
listener.successReported(AssertSuccessEvent(html.el))
223217
return html
224218
}
225219

exam-ws/src/main/java/io/github/adven27/concordion/extensions/exam/ws/WsPlugin.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
package io.github.adven27.concordion.extensions.exam.ws
22

33
import com.github.jknack.handlebars.Options
4-
import io.github.adven27.concordion.extensions.exam.core.ContentPrinter
54
import io.github.adven27.concordion.extensions.exam.core.ContentTypeConfig
6-
import io.github.adven27.concordion.extensions.exam.core.ContentVerifier
5+
import io.github.adven27.concordion.extensions.exam.core.ExamExtension.Companion.contentTypeConfig
76
import io.github.adven27.concordion.extensions.exam.core.ExamPlugin
8-
import io.github.adven27.concordion.extensions.exam.core.JsonPrinter
9-
import io.github.adven27.concordion.extensions.exam.core.JsonResolver
10-
import io.github.adven27.concordion.extensions.exam.core.JsonVerifier
11-
import io.github.adven27.concordion.extensions.exam.core.XmlPrinter
12-
import io.github.adven27.concordion.extensions.exam.core.XmlResolver
13-
import io.github.adven27.concordion.extensions.exam.core.XmlVerifier
147
import io.github.adven27.concordion.extensions.exam.core.commands.ExamCommand
158
import io.github.adven27.concordion.extensions.exam.core.handlebars.ExamHelper
169
import io.github.adven27.concordion.extensions.exam.core.handlebars.HANDLEBARS
@@ -34,9 +27,9 @@ class WsPlugin @JvmOverloads constructor(
3427
constructor(withBasePath: String, withPort: Int) : this(basePath = withBasePath, port = withPort)
3528

3629
private val contentTypeConfigs: MutableMap<ContentType, ContentTypeConfig> = mutableMapOf(
37-
ContentType.JSON to ContentTypeConfig(JsonResolver(), JsonVerifier(), JsonPrinter()),
38-
ContentType.XML to ContentTypeConfig(XmlResolver(), XmlVerifier(), XmlPrinter()),
39-
ContentType.TEXT to ContentTypeConfig(JsonResolver(), ContentVerifier.Default("text"), ContentPrinter.AsIs()),
30+
ContentType.JSON to contentTypeConfig("json"),
31+
ContentType.XML to contentTypeConfig("xml"),
32+
ContentType.TEXT to contentTypeConfig("text"),
4033
)
4134

4235
init {

0 commit comments

Comments
 (0)