Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master-v2
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/changelog-configuration.json
#	core/src/test/kotlin/demo/DataFetcherInterceptorDemo.kt
#	core/src/test/kotlin/org/neo4j/graphql/AugmentationTests.kt
#	core/src/test/kotlin/org/neo4j/graphql/CypherTests.kt
#	core/src/test/kotlin/org/neo4j/graphql/TranslatorExceptionTests.kt
#	core/src/test/kotlin/org/neo4j/graphql/asciidoc/AsciiDocParser.kt
#	core/src/test/kotlin/org/neo4j/graphql/asciidoc/ast/Table.kt
#	core/src/test/kotlin/org/neo4j/graphql/factories/AsciiDocTestFactory.kt
#	core/src/test/kotlin/org/neo4j/graphql/factories/CypherTestFactory.kt
#	readme.adoc
  • Loading branch information
Andy2003 committed Dec 19, 2024
2 parents 8375e5f + acb8c0d commit cf743db
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 88 deletions.
33 changes: 0 additions & 33 deletions core/src/test/kotlin/SchemaTest.kt

This file was deleted.

File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions core/src/test/kotlin/org/neo4j/graphql/AugmentationTests.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package org.neo4j.graphql

import demo.org.neo4j.graphql.utils.TestUtils.createTestsInPath
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.TestFactory
import org.neo4j.graphql.utils.GraphQLSchemaTestSuite
import org.neo4j.graphql.factories.GraphQLSchemaTestFactory
import org.neo4j.graphql.utils.TestUtils.createTestsInPath

class AugmentationTests {

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `augmentation-tests`() = GraphQLSchemaTestSuite("augmentation-tests.adoc").generateTests()
fun `augmentation-tests`() = GraphQLSchemaTestFactory("augmentation-tests.adoc").generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `schema-operations-tests`() = GraphQLSchemaTestSuite("schema-operations-tests.adoc").generateTests()
fun `schema-operations-tests`() = GraphQLSchemaTestFactory("schema-operations-tests.adoc").generateTests()


@TestFactory
fun `schema augmentation tests v2`() =
createTestsInPath("tck-test-files/schema/v2", { GraphQLSchemaTestSuite(it).generateTests() })
createTestsInPath("tck-test-files/schema/v2", { GraphQLSchemaTestFactory(it).generateTests() })
}
34 changes: 17 additions & 17 deletions core/src/test/kotlin/org/neo4j/graphql/CypherTests.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.neo4j.graphql

import apoc.date.Date
import demo.org.neo4j.graphql.utils.TestUtils.createTestsInPath
import org.junit.jupiter.api.*
import org.neo4j.driver.AuthTokens
import org.neo4j.driver.Driver
import org.neo4j.driver.GraphDatabase
import org.neo4j.graphql.utils.CypherTestSuite
import org.neo4j.graphql.factories.CypherTestFactory
import org.neo4j.graphql.utils.TestUtils.createTestsInPath
import org.neo4j.harness.Neo4j
import org.neo4j.harness.Neo4jBuilders
import java.nio.file.Path
Expand Down Expand Up @@ -37,66 +37,66 @@ class CypherTests {

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `cypher-directive-tests`() = CypherTestSuite("cypher-directive-tests.adoc", driver).generateTests()
fun `cypher-directive-tests`() = CypherTestFactory("cypher-directive-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `dynamic-property-tests`() = CypherTestSuite("dynamic-property-tests.adoc", driver).generateTests()
fun `dynamic-property-tests`() = CypherTestFactory("dynamic-property-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `filter-tests`() = CypherTestSuite("filter-tests.adoc", driver).generateTests()
fun `filter-tests`() = CypherTestFactory("filter-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `relationship-tests`() = CypherTestSuite("relationship-tests.adoc", driver).generateTests()
fun `relationship-tests`() = CypherTestFactory("relationship-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `movie-tests`() = CypherTestSuite("movie-tests.adoc", driver).generateTests()
fun `movie-tests`() = CypherTestFactory("movie-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `property-tests`() = CypherTestSuite("property-tests.adoc", driver).generateTests()
fun `property-tests`() = CypherTestFactory("property-tests.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `translator-tests1`() = CypherTestSuite("translator-tests1.adoc", driver).generateTests()
fun `translator-tests1`() = CypherTestFactory("translator-tests1.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `translator-tests2`() = CypherTestSuite("translator-tests2.adoc", driver).generateTests()
fun `translator-tests2`() = CypherTestFactory("translator-tests2.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `translator-tests3`() = CypherTestSuite("translator-tests3.adoc", driver).generateTests()
fun `translator-tests3`() = CypherTestFactory("translator-tests3.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `translator-tests-custom-scalars`() =
CypherTestSuite("translator-tests-custom-scalars.adoc", driver).generateTests()
CypherTestFactory("translator-tests-custom-scalars.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `optimized-query-for-filter`() = CypherTestSuite("optimized-query-for-filter.adoc", driver).generateTests()
fun `optimized-query-for-filter`() = CypherTestFactory("optimized-query-for-filter.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `custom-fields`() = CypherTestSuite("custom-fields.adoc", driver).generateTests()
fun `custom-fields`() = CypherTestFactory("custom-fields.adoc", driver).generateTests()

@Disabled("This test is disabled because it is not yet migrated")
@TestFactory
fun `test issues`() = createTestsInPath("issues", { CypherTestSuite(it, driver).generateTests() })
fun `test issues`() = createTestsInPath("issues", { CypherTestFactory(it, driver).generateTests() })

@TestFactory
fun `new cypher tck tests v2`() =
createTestsInPath("tck-test-files/cypher/v2", { CypherTestSuite(it, driver).generateTests() })
createTestsInPath("tck-test-files/cypher/v2", { CypherTestFactory(it, driver).generateTests() })

@TestFactory
fun `integration-tests`() =
createTestsInPath(
"integration-test-files",
{ CypherTestSuite(it, driver, createMissingBlocks = false).generateTests() })
{ CypherTestFactory(it, driver, createMissingBlocks = false).generateTests() })

companion object {
private val INTEGRATION_TESTS = System.getProperty("neo4j-graphql-java.integration-tests", "false") == "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.org.neo4j.graphql.utils.asciidoc
package org.neo4j.graphql.asciidoc

import demo.org.neo4j.graphql.utils.asciidoc.ast.*
import org.neo4j.graphql.asciidoc.ast.*
import org.apache.commons.csv.CSVFormat
import java.io.File
import java.net.URI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

class Block(
parent: StructuralNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

import java.net.URI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

import java.net.URI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

import java.net.URI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

sealed class StructuralNode(
open val parent: StructuralNode?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils.asciidoc.ast
package org.neo4j.graphql.asciidoc.ast

import org.apache.commons.csv.CSVRecord
import java.net.URI
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.neo4j.graphql.asciidoc.ast

class ThematicBreak: StructuralNode(null)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.neo4j.graphql.utils
package org.neo4j.graphql.factories

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JsonSerializer
Expand All @@ -8,11 +8,11 @@ import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import com.intellij.rt.execution.junit.FileComparisonFailure
import demo.org.neo4j.graphql.utils.asciidoc.AsciiDocParser
import demo.org.neo4j.graphql.utils.asciidoc.ast.*
import org.junit.jupiter.api.DynamicContainer
import org.junit.jupiter.api.DynamicNode
import org.junit.jupiter.api.DynamicTest
import org.neo4j.graphql.asciidoc.AsciiDocParser
import org.neo4j.graphql.asciidoc.ast.*
import java.io.File
import java.io.FileWriter
import java.time.temporal.TemporalAmount
Expand All @@ -24,7 +24,7 @@ import kotlin.reflect.KMutableProperty1
* @param fileName the name of the test file
* @param relevantBlocks a list of pairs of filter functions and properties to set the found code blocks
*/
abstract class AsciiDocTestSuite<T>(
abstract class AsciiDocTestFactory<T>(
protected val fileName: String,
private val relevantBlocks: List<CodeBlockMatcher<T>>,
private val createMissingBlocks: Boolean = true
Expand Down Expand Up @@ -56,16 +56,20 @@ abstract class AsciiDocTestSuite<T>(
tests += DynamicTest.dynamicTest(
"Write updated Testfile",
srcLocation,
this@AsciiDocTestSuite::writeAdjustedTestFile
this@AsciiDocTestFactory::writeAdjustedTestFile
)
} else if (REFORMAT_TEST_FILE) {
tests += DynamicTest.dynamicTest("Reformat Testfile", srcLocation, this@AsciiDocTestSuite::reformatTestFile)
tests += DynamicTest.dynamicTest(
"Reformat Testfile",
srcLocation,
this@AsciiDocTestFactory::reformatTestFile
)
} else if (GENERATE_TEST_FILE_DIFF) {
// this test prints out the adjusted test file
tests += DynamicTest.dynamicTest(
"Adjusted Tests",
srcLocation,
this@AsciiDocTestSuite::printAdjustedTestFile
this@AsciiDocTestFactory::printAdjustedTestFile
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.neo4j.graphql.utils
package org.neo4j.graphql.factories

import com.fasterxml.jackson.module.kotlin.readValue
import com.jayway.jsonpath.JsonPath
import demo.org.neo4j.graphql.utils.InvalidQueryException
import demo.org.neo4j.graphql.utils.asciidoc.ast.CodeBlock
import demo.org.neo4j.graphql.utils.asciidoc.ast.Section
import demo.org.neo4j.graphql.utils.asciidoc.ast.Table
import graphql.ExceptionWhileDataFetching
import graphql.ExecutionInput
import graphql.GraphQL
Expand All @@ -29,10 +25,14 @@ import org.neo4j.driver.Driver
import org.neo4j.graphql.QueryContext
import org.neo4j.graphql.SchemaBuilder
import org.neo4j.graphql.SchemaConfig
import org.neo4j.graphql.asciidoc.ast.CodeBlock
import org.neo4j.graphql.asciidoc.ast.Section
import org.neo4j.graphql.asciidoc.ast.Table
import org.neo4j.graphql.custom_resolver.TestDataFetcher
import org.neo4j.graphql.driver.adapter.Neo4jAdapter
import org.neo4j.graphql.driver.adapter.Neo4jDriverAdapter
import org.neo4j.graphql.scalars.TemporalScalar
import org.neo4j.graphql.utils.InvalidQueryException
import org.opentest4j.AssertionFailedError
import org.threeten.extra.PeriodDuration
import java.io.File
Expand All @@ -47,8 +47,8 @@ import java.util.concurrent.FutureTask
import java.util.function.Consumer
import kotlin.reflect.full.findAnnotation

class CypherTestSuite(fileName: String, val driver: Driver? = null, createMissingBlocks: Boolean = true) :
AsciiDocTestSuite<CypherTestSuite.TestCase>(
class CypherTestFactory(fileName: String, val driver: Driver? = null, createMissingBlocks: Boolean = true) :
AsciiDocTestFactory<CypherTestFactory.TestCase>(
fileName,
listOf(
matcher("cypher", exactly = true) { t, c -> t.cypher.add(c) },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.neo4j.graphql.utils
package org.neo4j.graphql.factories

import demo.org.neo4j.graphql.utils.asciidoc.ast.CodeBlock
import demo.org.neo4j.graphql.utils.asciidoc.ast.Section
import graphql.language.InterfaceTypeDefinition
import graphql.language.UnionTypeDefinition
import graphql.schema.GraphQLScalarType
Expand All @@ -19,10 +17,12 @@ import org.junit.jupiter.api.DynamicTest
import org.neo4j.graphql.NoOpCoercing
import org.neo4j.graphql.SchemaBuilder
import org.neo4j.graphql.SchemaConfig
import org.neo4j.graphql.asciidoc.ast.CodeBlock
import org.neo4j.graphql.asciidoc.ast.Section
import org.opentest4j.AssertionFailedError
import java.util.*

class GraphQLSchemaTestSuite(fileName: String) : AsciiDocTestSuite<GraphQLSchemaTestSuite.TestCase>(
class GraphQLSchemaTestFactory(fileName: String) : AsciiDocTestFactory<GraphQLSchemaTestFactory.TestCase>(
fileName,
listOf(
matcher("graphql", exactly = true, setter = TestCase::augmentedSchema),
Expand Down Expand Up @@ -77,7 +77,8 @@ class GraphQLSchemaTestSuite(fileName: String) : AsciiDocTestSuite<GraphQLSchema
}
val actualSchema = SCHEMA_PRINTER.print(augmentedSchema)
targetSchemaBlock.generatedContent = actualSchema
throw AssertionFailedError("augmented schema differs for '$title'",
throw AssertionFailedError(
"augmented schema differs for '$title'",
expectedSchema?.let { SCHEMA_PRINTER.print(it) } ?: targetSchema,
actualSchema,
e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils
package org.neo4j.graphql.utils

import graphql.GraphQLError

Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/org/neo4j/graphql/utils/TestUtils.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.org.neo4j.graphql.utils
package org.neo4j.graphql.utils

import org.junit.jupiter.api.DynamicContainer
import org.junit.jupiter.api.DynamicNode
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ You find more usage examples in the:

== Demo

You can use the link:core/src/test/kotlin/GraphQLServer.kt[GraphQL Demo Server] to play around with the library.
You can use the link:core/src/test/kotlin/demo/GraphQLServer.kt[GraphQL Demo Server] to play around with the library.
It is running against a Neo4j instance at `bolt://localhost` (username: `neo4j`, password: `test`) containing the `:play movies` graph.

Use http://localhost:4567/graphql as your GraphQL URL.
Expand Down

0 comments on commit cf743db

Please sign in to comment.