Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .run/Reformat Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reformat Tests" type="JUnit" factoryName="JUnit">
<module name="neo4j-graphql-java"/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="directory"/>
<option name="VM_PARAMETERS" value="-ea -Dneo4j-graphql-java.reformat=true"/>
<dir value="$PROJECT_DIR$/core/src/test/kotlin/org/neo4j/graphql"/>
<method v="2">
<option name="Make" enabled="true"/>
</method>
</configuration>
</component>
43 changes: 24 additions & 19 deletions core/src/test/kotlin/org/neo4j/graphql/TranslatorExceptionTests.kt
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
package org.neo4j.graphql

import demo.org.neo4j.graphql.utils.asciidoc.ast.CodeBlock
import demo.org.neo4j.graphql.utils.asciidoc.ast.Section
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DynamicNode
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.TestFactory
import org.neo4j.graphql.utils.AsciiDocTestSuite
import java.util.stream.Stream

class TranslatorExceptionTests : AsciiDocTestSuite("translator-tests1.adoc") {
class TranslatorExceptionTests : AsciiDocTestSuite<CodeBlock>("translator-tests1.adoc", emptyList()) {

@TestFactory
fun createTests(): Stream<DynamicNode> {
return generateTests()
override fun createTestCase(section: Section): CodeBlock? {
return findSetupCodeBlocks(section, "graphql", mapOf("schema" to "true")).firstOrNull() ?: return null
}

override fun schemaTestFactory(schema: String): List<DynamicNode> {
val translator = Translator(SchemaBuilder.buildSchema(schema))
override fun createTests(testCase: CodeBlock, section: Section, ignoreReason: String?): List<DynamicNode> {
if (section.title != "Tests") {
return emptyList()
}
return listOf(
DynamicTest.dynamicTest("unknownType") {
Assertions.assertThrows(InvalidQueryException::class.java) {
translator.translate(
"""
{
company {
name
}
}
Translator(SchemaBuilder.buildSchema(testCase.content)).translate(
"""
{
company {
name
}
}
"""
)
}
},
DynamicTest.dynamicTest("mutation") {
Assertions.assertThrows(InvalidQueryException::class.java) {
translator.translate(
Translator(SchemaBuilder.buildSchema(testCase.content)).translate(
"""
{
createPerson()
}
""".trimIndent()
{
createPerson()
}
""".trimIndent()
)
}
}

)
}

@TestFactory
fun createTests(): Stream<DynamicNode> = generateTests()
}
Loading
Loading