Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions audits/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>com.antwerkz.super-expressive</groupId>
<artifactId>super-expressive</artifactId>
Expand Down
24 changes: 13 additions & 11 deletions audits/src/main/kotlin/dev/morphia/audits/RstAuditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ class RstAuditor(val type: OperatorType) {
val docRoot = File(DOC_ROOT, "modules/ROOT/pages/${type.docsName()}.adoc")
docRoot.writeText(
"""
[%header,cols="1,2,3"]
|===
|Operator|Docs|Test Examples
[%header,cols="1,2,3"]
|===
|Operator|Docs|Test Examples


"""
.trimIndent()
)
Expand Down Expand Up @@ -257,17 +257,19 @@ class RstAuditor(val type: OperatorType) {
if (!example.folder.path.contains("aggregation")) {
method.setBody(
"""
|testQuery((query) -> query.filter( ));
| """
|testQuery((query) -> query.filter( ));
|
"""
.trimMargin()
)
} else {
method.setBody(
"""
|testPipeline(aggregation -> aggregation
| .pipeline(
|
|)); """
|testPipeline(aggregation -> aggregation
| .pipeline(
|
|));
"""
.trimMargin()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dev.morphia.audits.model.Operator
import dev.morphia.audits.model.OperatorType.EXPRESSION
import dev.morphia.audits.model.OperatorType.STAGE
import java.io.File
import org.testng.annotations.Test
import org.junit.jupiter.api.Test

class AggregationAuditTest : BaseAuditTest() {

Expand Down
10 changes: 5 additions & 5 deletions audits/src/test/kotlin/dev/morphia/audits/BaseAuditTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ package dev.morphia.audits

import dev.morphia.audits.model.Results
import java.io.File
import org.testng.Assert.assertEquals
import org.testng.Assert.assertTrue
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue

open class BaseAuditTest {
protected fun validate(results: Results) {
assertEquals(
results.created.size,
0,
results.created.size,
"All existing operators should be represented: " +
results.created.joinToString("\n\t", prefix = "\n\t") { it.operator },
)
assertEquals(
results.noExamples.size,
0,
results.noExamples.size,
"All existing operators should have examples: " +
results.noExamples.joinToString("\n\t", prefix = "\n\t") {
"${it.operator.name}: ${it.name}"
},
)
assertEquals(
results.noTest.size,
0,
results.noTest.size,
"All existing operators should have test cases: " +
results.noTest.joinToString("\n\t", prefix = "\n\t") {
"${it.operator}: ${it.testSource.relativeTo(File("../").absoluteFile)}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.morphia.audits

import org.testng.annotations.Test
import org.junit.jupiter.api.Test

class OperationAuditTest {
@Test
Expand Down Expand Up @@ -33,6 +33,6 @@ class OperationAuditTest {
}

println("$remaining items to handle")
// assertEquals(created, 0)
// assertEquals(0, created)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dev.morphia.audits.model.Operator
import dev.morphia.audits.model.OperatorType.FILTER
import dev.morphia.audits.model.OperatorType.UPDATE
import java.io.File
import org.testng.annotations.Test
import org.junit.jupiter.api.Test

class QueryAuditTest : BaseAuditTest() {
@Test
Expand Down
6 changes: 3 additions & 3 deletions audits/src/test/kotlin/dev/morphia/audits/SinceAuditTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dev.morphia.audits
import dev.morphia.audits.model.MorphiaMethod
import dev.morphia.audits.model.State
import dev.morphia.audits.model.Version
import org.testng.Assert
import org.junit.jupiter.api.Assertions

class SinceAuditTest {
fun deprecations() {
Expand All @@ -15,7 +15,7 @@ class SinceAuditTest {
"dev.morphia.query.LegacyQuery#execute()Ldev/morphia/query/internal/MorphiaCursor;"]

method as MorphiaMethod
Assert.assertEquals(State.DEPRECATED, method.versions[Version.v2_1_0_SNAPSHOT])
Assert.assertEquals(State.ABSENT, method.versions[Version.v1_6_0_SNAPSHOT])
Assertions.assertEquals(method.versions[Version.v2_1_0_SNAPSHOT], State.DEPRECATED)
Assertions.assertEquals(method.versions[Version.v1_6_0_SNAPSHOT], State.ABSENT)
}
}
26 changes: 16 additions & 10 deletions audits/src/test/kotlin/dev/morphia/audits/rst/ExampleValidator.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.morphia.audits.rst

import org.testng.Assert
import org.junit.jupiter.api.Assertions

data class ExampleValidator(
val data: Boolean = true,
Expand All @@ -12,12 +12,12 @@ data class ExampleValidator(

fun action(example: OperatorExample) {
if (action) {
Assert.assertNotNull(
Assertions.assertNotNull(
example.actionBlock,
"Should have an action block for ${example.name}",
)
} else {
Assert.assertNull(
Assertions.assertNull(
example.actionBlock,
"Should not have an action block for ${example.name}",
)
Expand All @@ -26,20 +26,26 @@ data class ExampleValidator(

fun data(example: OperatorExample) {
if (data) {
Assert.assertNotNull(example.dataBlock, "Should have a data block for ${example.name}")
Assertions.assertNotNull(
example.dataBlock,
"Should have a data block for ${example.name}",
)
} else {
Assert.assertNull(example.dataBlock, "Should not have a data block for ${example.name}")
Assertions.assertNull(
example.dataBlock,
"Should not have a data block for ${example.name}",
)
}
}

fun expected(example: OperatorExample) {
if (expected) {
Assert.assertNotNull(
Assertions.assertNotNull(
example.expectedBlock,
"Should have an expected block for ${example.name}",
)
} else {
Assert.assertNull(
Assertions.assertNull(
example.expectedBlock,
"Should not have an expected block for ${example.name}",
)
Expand All @@ -48,19 +54,19 @@ data class ExampleValidator(

fun index(example: OperatorExample) {
if (index) {
Assert.assertNotNull(
Assertions.assertNotNull(
example.indexBlock,
"Should have a index block for ${example.name}",
)
} else {
Assert.assertNull(
Assertions.assertNull(
example.indexBlock,
"Should not have a index block for ${example.name}",
)
}
}

fun name(example: OperatorExample, name: String) {
Assert.assertEquals(example.name, name, "Should have the correct name")
Assertions.assertEquals(name, example.name, "Should have the correct name")
}
}
Loading