From bc9731fa4a84dc40ea43d0695dab9a0fb4a5c55e Mon Sep 17 00:00:00 2001 From: Dirk Groot Date: Fri, 31 Mar 2023 12:32:58 +0200 Subject: [PATCH] Refactoring - Move formatting tests to a separate `formatter` package - Rename `StructurizrDSLParserTest` to `StructurizrDSLCodeInsightTest`, because it can be used for more than just testing the parser --- .../dsl/editing/{ => formatter}/FormatterTest.kt | 6 +++--- .../IndentationTest.kt} | 4 ++-- .../{FormatterSpacingTest.kt => formatter/SpacingTest.kt} | 4 ++-- .../dsl/parser/ElementsWithBlocksOfElementsTest.kt | 4 ++-- .../dsl/parser/ElementsWithPropertyBlocksTest.kt | 4 ++-- .../structurizr/dsl/parser/IdentifierAssignmentTest.kt | 4 ++-- .../dsl/parser/LineWithIdentifierReferencesTest.kt | 4 ++-- .../dirkgroot/structurizr/dsl/parser/NonCodeElementsTest.kt | 4 ++-- .../nl/dirkgroot/structurizr/dsl/parser/RelationshipTest.kt | 4 ++-- .../nl/dirkgroot/structurizr/dsl/parser/ScriptBlockTest.kt | 4 ++-- .../structurizr/dsl/parser/SingleLineElementsTest.kt | 4 ++-- ...izrDSLParserTest.kt => StructurizrDSLCodeInsightTest.kt} | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) rename src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/{ => formatter}/FormatterTest.kt (74%) rename src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/{FormatterIndentationTest.kt => formatter/IndentationTest.kt} (98%) rename src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/{FormatterSpacingTest.kt => formatter/SpacingTest.kt} (94%) rename src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/{StructurizrDSLParserTest.kt => StructurizrDSLCodeInsightTest.kt} (96%) diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/FormatterTest.kt similarity index 74% rename from src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterTest.kt rename to src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/FormatterTest.kt index c445344..da1e58c 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/FormatterTest.kt @@ -1,10 +1,10 @@ -package nl.dirkgroot.structurizr.dsl.editing +package nl.dirkgroot.structurizr.dsl.editing.formatter import com.intellij.openapi.command.WriteCommandAction import com.intellij.psi.codeStyle.CodeStyleManager -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest -open class FormatterTest : StructurizrDSLParserTest() { +abstract class FormatterTest : StructurizrDSLCodeInsightTest() { protected fun assertFormattingResult(code: String, expectedResult: String) { val file = fixture.addFileToProject("test.dsl", code) fixture.openFileInEditor(file.virtualFile) diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterIndentationTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/IndentationTest.kt similarity index 98% rename from src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterIndentationTest.kt rename to src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/IndentationTest.kt index 7b5bef1..29c8414 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterIndentationTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/IndentationTest.kt @@ -1,8 +1,8 @@ -package nl.dirkgroot.structurizr.dsl.editing +package nl.dirkgroot.structurizr.dsl.editing.formatter import org.junit.jupiter.api.Test -class FormatterIndentationTest : FormatterTest() { +class IndentationTest : FormatterTest() { @Test fun `block with single line element`() { assertFormattingResult( diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterSpacingTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/SpacingTest.kt similarity index 94% rename from src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterSpacingTest.kt rename to src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/SpacingTest.kt index 5e27883..e1ac762 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/FormatterSpacingTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/editing/formatter/SpacingTest.kt @@ -1,8 +1,8 @@ -package nl.dirkgroot.structurizr.dsl.editing +package nl.dirkgroot.structurizr.dsl.editing.formatter import org.junit.jupiter.api.Test -class FormatterSpacingTest : FormatterTest() { +class SpacingTest : FormatterTest() { @Test fun arguments() { assertFormattingResult( diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithBlocksOfElementsTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithBlocksOfElementsTest.kt index 4dcacef..c52889a 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithBlocksOfElementsTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithBlocksOfElementsTest.kt @@ -1,11 +1,11 @@ package nl.dirkgroot.structurizr.dsl.parser import nl.dirkgroot.structurizr.dsl.lexer.KEYWORDS_WITH_BLOCKS -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.TestFactory -class ElementsWithBlocksOfElementsTest : StructurizrDSLParserTest() { +class ElementsWithBlocksOfElementsTest : StructurizrDSLCodeInsightTest() { @TestFactory fun `empty block`() = KEYWORDS_WITH_BLOCKS.map { (keyword, _) -> dynamicTest(keyword) { diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithPropertyBlocksTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithPropertyBlocksTest.kt index 5c92cac..ceea916 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithPropertyBlocksTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ElementsWithPropertyBlocksTest.kt @@ -1,11 +1,11 @@ package nl.dirkgroot.structurizr.dsl.parser import nl.dirkgroot.structurizr.dsl.lexer.KEYWORDS_WITH_PROPERTY_BLOCKS -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.TestFactory -class ElementsWithPropertyBlocksTest : StructurizrDSLParserTest() { +class ElementsWithPropertyBlocksTest : StructurizrDSLCodeInsightTest() { @TestFactory fun `empty block`() = KEYWORDS_WITH_PROPERTY_BLOCKS.map { (keyword, _) -> dynamicTest(keyword) { diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/IdentifierAssignmentTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/IdentifierAssignmentTest.kt index 71fe186..d783297 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/IdentifierAssignmentTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/IdentifierAssignmentTest.kt @@ -1,11 +1,11 @@ package nl.dirkgroot.structurizr.dsl.parser import nl.dirkgroot.structurizr.dsl.lexer.KEYWORDS -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.TestFactory -class IdentifierAssignmentTest : StructurizrDSLParserTest() { +class IdentifierAssignmentTest : StructurizrDSLCodeInsightTest() { @TestFactory fun `identifier assignment to single line element`() = KEYWORDS.map { (keyword, _) -> dynamicTest(keyword) { diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/LineWithIdentifierReferencesTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/LineWithIdentifierReferencesTest.kt index a51c397..0f66d4d 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/LineWithIdentifierReferencesTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/LineWithIdentifierReferencesTest.kt @@ -1,9 +1,9 @@ package nl.dirkgroot.structurizr.dsl.parser -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.Test -class LineWithIdentifierReferencesTest : StructurizrDSLParserTest() { +class LineWithIdentifierReferencesTest : StructurizrDSLCodeInsightTest() { @Test fun `single identifier reference on one line`() { assertPsiTree( diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/NonCodeElementsTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/NonCodeElementsTest.kt index efc1c2e..156a498 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/NonCodeElementsTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/NonCodeElementsTest.kt @@ -1,9 +1,9 @@ package nl.dirkgroot.structurizr.dsl.parser -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.Test -class NonCodeElementsTest : StructurizrDSLParserTest() { +class NonCodeElementsTest : StructurizrDSLCodeInsightTest() { @Test fun `empty line`() { assertPsiTree("\n", """PsiWhiteSpace \n""") diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/RelationshipTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/RelationshipTest.kt index 56e9ca0..9e5dfc0 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/RelationshipTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/RelationshipTest.kt @@ -1,9 +1,9 @@ package nl.dirkgroot.structurizr.dsl.parser -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.Test -class RelationshipTest : StructurizrDSLParserTest() { +class RelationshipTest : StructurizrDSLCodeInsightTest() { @Test fun `explicit without arguments`() { assertPsiTree( diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ScriptBlockTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ScriptBlockTest.kt index dbe202a..da7d050 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ScriptBlockTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/ScriptBlockTest.kt @@ -1,9 +1,9 @@ package nl.dirkgroot.structurizr.dsl.parser -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.Test -class ScriptBlockTest : StructurizrDSLParserTest() { +class ScriptBlockTest : StructurizrDSLCodeInsightTest() { @Test fun `empty script block`() { assertPsiTree( diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/SingleLineElementsTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/SingleLineElementsTest.kt index 77ec34c..a2a9c9a 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/SingleLineElementsTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/parser/SingleLineElementsTest.kt @@ -1,12 +1,12 @@ package nl.dirkgroot.structurizr.dsl.parser import nl.dirkgroot.structurizr.dsl.lexer.KEYWORDS_WITH_BLOCKS -import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest +import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLCodeInsightTest import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestFactory -class SingleLineElementsTest : StructurizrDSLParserTest() { +class SingleLineElementsTest : StructurizrDSLCodeInsightTest() { @TestFactory fun `without argument`() = KEYWORDS_WITH_BLOCKS.map { (keyword, _) -> dynamicTest(keyword) { diff --git a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLParserTest.kt b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLCodeInsightTest.kt similarity index 96% rename from src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLParserTest.kt rename to src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLCodeInsightTest.kt index 54817b0..b17af95 100644 --- a/src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLParserTest.kt +++ b/src/test/kotlin/nl/dirkgroot/structurizr/dsl/support/StructurizrDSLCodeInsightTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach @RunInEdt -abstract class StructurizrDSLParserTest { +abstract class StructurizrDSLCodeInsightTest { protected lateinit var fixture: CodeInsightTestFixture protected lateinit var project: Project