-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace context overloads with archunit test
- Loading branch information
Showing
3 changed files
with
44 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/src/test/kotlin/graphql/nadel/validation/NadelValidationDefinitionsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package graphql.nadel.validation | ||
|
||
import com.tngtech.archunit.base.DescribedPredicate | ||
import com.tngtech.archunit.base.DescribedPredicate.not | ||
import com.tngtech.archunit.core.domain.JavaClass | ||
import com.tngtech.archunit.core.domain.JavaMethodCall | ||
import com.tngtech.archunit.core.importer.ClassFileImporter | ||
import com.tngtech.archunit.core.importer.ImportOption | ||
import com.tngtech.archunit.lang.conditions.ArchConditions.callMethodWhere | ||
import com.tngtech.archunit.lang.conditions.ArchConditions.not | ||
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes | ||
import kotlin.test.Test | ||
|
||
class NadelValidationDefinitionsTest { | ||
@Test | ||
fun `do not use parse definitions functions in validation`() { | ||
val importedClasses = ClassFileImporter() | ||
.withImportOption(ImportOption.DoNotIncludeTests()) | ||
.importPackages("graphql.nadel.validation") | ||
|
||
val rule = classes() | ||
.that( | ||
not( | ||
JavaClass.Predicates.belongTo( | ||
JavaClass.Predicates.simpleNameEndingWith("DefinitionParser") | ||
), | ||
), | ||
) | ||
.should( | ||
not( | ||
callMethodWhere( | ||
object : DescribedPredicate<JavaMethodCall>("definition parse methods") { | ||
override fun test(invocation: JavaMethodCall): Boolean { | ||
return invocation.targetOwner.getPackage().name.startsWith("graphql.nadel.definition") | ||
&& invocation.target.name.startsWith("parse") | ||
} | ||
} | ||
), | ||
), | ||
) | ||
|
||
rule.check(importedClasses) | ||
} | ||
} |