Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
- Move formatting tests to a separate `formatter` package
- Rename `StructurizrDSLParserTest` to `StructurizrDSLCodeInsightTest`,
  because it can be used for more than just testing the parser
  • Loading branch information
dirkgroot committed Mar 31, 2023
1 parent 13d2fc1 commit bc9731f
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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""")
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bc9731f

Please sign in to comment.