Skip to content

Commit

Permalink
2024.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
toronik committed Aug 24, 2024
1 parent 7310f7c commit d8707e5
Show file tree
Hide file tree
Showing 24 changed files with 234 additions and 188 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext.kotlin_version = '2.0.0'
ext.klogging_version = '3.0.5'
ext.jacksonKt_version = '2.17.1'
ext.libVersion = '2024.0.9'
ext.libVersion = '2024.0.10'
repositories {
mavenCentral()
maven {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ open class AdocExtension : ConcordionExtension {
}
}

private fun text(i: InputStream) = "include::${"/specs/.asciidoctorconfig".findResource().path}[]" +
System.lineSeparator() +
InputStreamReader(i).readText()
private fun text(i: InputStream) =
(ExamExtension::class.java.classLoader.getResource(".asciidoctorconfig")?.readText() ?: "") +
System.lineSeparator() +
ExamExtension::class.java.getResource("/specs/.asciidoctorconfig")?.path?.let { "include::$it[]" } +
System.lineSeparator() +
InputStreamReader(i).readText()

private fun addStyles(ex: ConcordionExtender) {
ex.linkedCss(BASE_CM, "enable-codemirror.css")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.adven27.concordion.extensions.exam.core

import mu.KLogging
import org.asciidoctor.ast.Cell
import org.asciidoctor.ast.DescriptionList
import org.asciidoctor.ast.Document
import org.asciidoctor.ast.StructuralNode
import org.asciidoctor.ast.Table
Expand Down Expand Up @@ -31,6 +32,7 @@ open class ExamTreeProcessor : Treeprocessor() {
b.style == "e-execute" -> propagateToAttrs(b, executeBlock())?.let { blocks[i] = it }
b.style == "open" -> processNode(b).also { propagateToAttrs(b, openBlock())?.let { blocks[i] = it } }
b is AstList -> propagateToAttrs(b, listBlock())?.let { blocks[i] = it }
b is DescriptionList -> b.items.map { it.description }.map(::processNode)
b.blocks.isNotEmpty() -> processNode(b)
b is Table -> b.body.flatMap { it.cells }.map { c -> (c as Cell).innerDocument?.let(::processNode) }
.also { propagateToAttrs(b, tableBlock())?.let { blocks[i] = it } }
Expand Down
77 changes: 77 additions & 0 deletions exam-core/src/main/resources/.asciidoctorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
:table-caption!:
:json: source,json,subs="+attributes"
:ExpectedToFail: .ExpectedToFail
:before: #before

:mq-params: cols="h,1", role=params
:mq-headers: cols="h,1", role=headers
:mq-set: cols=a, grid=rows, frame=ends, e-mq-set=
:mq-check: cols=a, grid=rows, frame=ends, e-mq-check=
:mq-check-await: cols=a, grid=rows, frame=ends, e-await=6s, e-mq-check=
:mq-contains: e-contains=
:mq-any-order: e-contains='any-order'
:mq-clean: e-mq-clean

:db-datasource: e-ds=
:db-show: e-db-show=
:db-show-save-to: e-saveTo=
:db-check: e-db-check=
:db-check-await: e-await=6s, e-db-check=
:db-orderBy: e-orderBy=
:db-where: e-where=
:db-set: e-db-set=
:db-set-insert: e-operation=insert, e-db-set=
:db-set-update: e-operation=update, e-db-set=
:db-set-delete: e-operation=delete, e-db-set=
:db-set-refresh: e-operation=refresh, e-db-set=
:db-operation: e-operation=
:db-operation-insert: e-operation=insert
:db-operation-update: e-operation=update
:db-operation-delete: e-operation=delete
:db-operation-refresh: e-operation=refresh
:db-clean: e-db-clean

:http: e-http=
:http-await: e-await=6s, e-http=
:http-where: .where

:set: e-set=
:eq: e-eq=
:eq-json: e-eq-json=
:eq-xml: e-eq-xml=
:verifier: e-verifier=
:await: e-await=
:jsonIgnoreExtraFields: e-verifier=jsonIgnoreExtraFields
:echo: e-echo=
:exec: e-execute=
:exec-on-paragraph: role=e-execute=
:verify-rows: e-verify-rows=
:verify-rows-strategy: e-match-strategy=
:verify-rows-best-match: e-match-strategy=BestMatch, e-verify-rows=
:run: role=e-run
:nil: {{NULL}}
:t0: {{at}}
:3d-: {{at '-3d'}}
:2d-: {{at '-2d'}}
:1d-: {{at '-1d'}}
:3h-: {{at '-3h'}}
:2h-: {{at '-2h'}}
:1h-: {{at '-1h'}}
:1h: {{at '1h'}}
:2h: {{at '2h'}}
:3h: {{at '3h'}}
:1d: {{at '1d'}}
:2d: {{at '2d'}}
:3d: {{at '3d'}}
:mh-100: role=mh-100
:mh-200: role=mh-200
:collapse: %collapsible
:just: {{within '10s'}}
:any-num: {{number}}
:any-str: {{string}}
:any-bool: {{bool}}
:any-datetime: {{iso}}
:any-date: {{isoDate}}
:any-not-null: {{notNull}}
:any-uuid: {{uuid}}
:any: {{ignore}}
26 changes: 2 additions & 24 deletions example/src/test/resources/specs/.asciidoctorconfig
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
:table-caption!:
:mq-params: cols="h,1", role=params
:mq-headers: cols="h,1", role=headers
:mq-set: cols=a, grid=rows, frame=ends, e-mq-set=
:mq-check: cols=a, grid=rows, frame=ends, e-mq-check=
:mq-check-await: cols=a, grid=rows, frame=ends, e-await=1s, e-mq-check=
:mq-clean: e-mq-clean
:db-check: e-db-check=
:db-set: e-db-set=
:db-clean: e-db-clean
:orderBy: e-orderBy=
:http: e-http=
:set: e-set=
:run: role=e-run
:nil: {{NULL}}
:jsonIgnoreExtraFields: e-verifier=jsonIgnoreExtraFields
:just: {{within '10s'}}
:t0: {{at}}
:2d-: {{at '-2d'}}
:1d-: {{at '-1d'}}
:2h-: {{at '-2h'}}
:1h-: {{at '-1h'}}
:1h: {{at '1h'}}
:mh-100: role=mh-100
:mh-200: role=mh-200
:db-check-await: e-await=1s, e-db-check=
:http-await: e-await=1s, e-http=
6 changes: 3 additions & 3 deletions example/src/test/resources/specs/DbCheckContentTypes.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= DB Check Content Types

[#before]
[{before}]
.Before each example
****
.content_types
Expand All @@ -20,7 +20,7 @@ include::DbCheckContentTypes.adoc[tags=db-check-ct]
====
//tag::db-check-ct[]
.content_types
[%header, cols="1a,1a,1a", {db-check}, {orderBy}id]
[cols="1a,1a,1a", {db-check}, {db-orderBy}id]
|===
|data_json |data_json_with_extra_fields |data_xml
Expand Down Expand Up @@ -57,7 +57,7 @@ include::DbCheckContentTypes.adoc[tags=db-check-ct]
.Failures
====
.content_types
[cols="a,a", {db-check}, {orderBy}id]
[cols="a,a", {db-check}, {db-orderBy}id]
|===
|data_json |data_xml

Expand Down
28 changes: 14 additions & 14 deletions example/src/test/resources/specs/DbCheckFailures.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= DB Check Failures

[#before]
[{before}]
.Before each example
****
Given table
Expand All @@ -15,7 +15,7 @@ id, name, price, created_At
,===
****

[.ExpectedToFail]
[{ExpectedToFail}]
.Surplus rows
====
Wrong expectation
Expand All @@ -29,21 +29,21 @@ id, name, price, created_At
,===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Surplus rows: await
====
Wrong expectation

.product
[{db-check},e-await=1s]
[{db-check-await}]
,===
id, name, price, created_At

1, Model A, 1.70, {t0}
,===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Missing rows
====
Wrong expectation
Expand All @@ -59,13 +59,13 @@ id, name, price, created_At
,===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Missing rows: await
====
Wrong expectation

.product
[{db-check},e-await="1s,500ms"]
[{db-check},{await}"1s,500ms"]
,===
id, name, price, created_At

Expand All @@ -75,7 +75,7 @@ id, name, price, created_At
,===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Wrong content
====
Wrong expectation
Expand All @@ -85,22 +85,22 @@ Wrong expectation
,===
id, name, price, created_At

1, {{number}}, 0, {just}
2, Model B, {{string}}, {just}
1, {any-num}, 0, {just}
2, Model B, {any-str}, {just}
,===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Wrong content: await
====
Wrong expectation

.product
[{db-check},e-await="1s,,500ms"]
[{db-check},{await}"1s,,500ms"]
,===
id, name, price, created_At

1, {{number}}, 0, {just}
2, Model B, {{string}}, {just}
1, {any-num}, 0, {just}
2, Model B, {any-str}, {just}
,===
====
14 changes: 7 additions & 7 deletions example/src/test/resources/specs/DbSetOperations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

https://dbunit.sourceforge.net/dbunit/components.html#databaseoperation[DbUnit operations] allows to append, update and delete rows.

[#before]
[{before}]
.Before each example
****
Given:
Expand All @@ -29,7 +29,7 @@ When append row:
//tag::db-insert[]
.product
[e-db-set=, e-operation=insert]
[{db-set-insert}]
,===
id, name, price
Expand All @@ -40,7 +40,7 @@ id, name, price
Then row added:
.product
[e-db-check=]
[{db-check}]
,===
id, name, price
Expand All @@ -62,7 +62,7 @@ When update row
//tag::db-update[]
.product
[e-db-set=, e-operation=update]
[{db-set-update}]
,===
id, name, price
Expand All @@ -73,7 +73,7 @@ id, name, price
Then second row updated
.product
[e-db-check=]
[{db-check}]
,===
id, name, price
Expand All @@ -94,7 +94,7 @@ When delete row
//tag::db-delete[]
.product
[e-db-set=, e-operation=delete]
[{db-set-delete}]
,===
id
Expand All @@ -105,7 +105,7 @@ id
Then second row deleted
.product
[e-db-check=]
[{db-check}]
,===
id, name, price
Expand Down
14 changes: 7 additions & 7 deletions example/src/test/resources/specs/MqCheckFailures.adoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
= Message Queue Check Failures

[#before]
[{before}]
.Before each example
****
[{mq-clean}]#myQueue# is empty.
****

[.ExpectedToFail]
[{ExpectedToFail}]
.Surplus messages
====
.Got message
Expand All @@ -21,7 +21,7 @@
|===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Surplus messages: await
====
.Got message
Expand All @@ -36,7 +36,7 @@
|===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Missing messages
====
Got no messages.
Expand All @@ -51,7 +51,7 @@ Got no messages.
|===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Missing messages: await
====
Got no messages.
Expand All @@ -66,7 +66,7 @@ Got no messages.
|===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Wrong payload
====
.Got message
Expand Down Expand Up @@ -173,7 +173,7 @@ h1, {{isoDate (at '-1d')}}
|===
====

[.ExpectedToFail]
[{ExpectedToFail}]
.Big message
====
.Got message
Expand Down
Loading

0 comments on commit d8707e5

Please sign in to comment.