Skip to content

Commit

Permalink
refactor: Replace usages of org.hamcrest.MatcherAssert with com.felip…
Browse files Browse the repository at this point in the history
…ebz.flr.tests.Assertions
  • Loading branch information
felipebz committed May 15, 2024
1 parent a256b94 commit 5a7dc47
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
package org.sonar.plsqlopen.lexer

import com.felipebz.flr.api.TokenType
import com.felipebz.flr.test.lexer.LexerMatchers.hasComment
import com.felipebz.flr.test.lexer.LexerMatchers.hasToken
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.not
import org.hamcrest.MatcherAssert.assertThat
import com.felipebz.flr.tests.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.sonar.plsqlopen.parser.PlSqlParser
import org.sonar.plsqlopen.squid.PlSqlConfiguration
Expand All @@ -38,14 +35,14 @@ class PlSqlLexerTest {

@Test
fun multilineComment() {
assertThat(lexer.lex("/* multine \n comment */"), hasComment("/* multine \n comment */"))
assertThat(lexer.lex("/**/"), hasComment("/**/"))
assertThat(lexer.lex("/* multine \n comment */")).hasComment("/* multine \n comment */")
assertThat(lexer.lex("/**/")).hasComment("/**/")
}

@Test
fun inlineComment() {
assertThat(lexer.lex("before -- inline \n new line"), hasComment("-- inline "))
assertThat(lexer.lex("--"), hasComment("--"))
assertThat(lexer.lex("before -- inline \n new line")).hasComment("-- inline ")
assertThat(lexer.lex("--")).hasComment("--")
}

@Test
Expand Down Expand Up @@ -152,11 +149,11 @@ class PlSqlLexerTest {
}

private fun assertThatIsToken(sourceCode: String, tokenType: TokenType) {
assertThat(lexer.lex(sourceCode), hasToken(sourceCode, tokenType))
assertThat(lexer.lex(sourceCode)).hasToken(sourceCode, tokenType)
}

private fun assertThatIsNotToken(sourceCode: String, tokenType: TokenType) {
assertThat(lexer.lex(sourceCode), not(hasToken(sourceCode, tokenType)))
assertThat(lexer.lex(sourceCode)).doesNotHaveToken(sourceCode, tokenType)
}

@Test
Expand All @@ -169,7 +166,7 @@ class PlSqlLexerTest {
"y := 'Another unrelated string!';\n" +
"end;")

assertThat(node.getDescendants(PlSqlGrammar.ASSIGNMENT_STATEMENT).size, `is`(2))
assertThat(node.getDescendants(PlSqlGrammar.ASSIGNMENT_STATEMENT)).hasSize(2)
}

@Test
Expand All @@ -183,7 +180,7 @@ class PlSqlLexerTest {
"]';\n" +
"end;")

assertThat(node.getDescendants(PlSqlGrammar.ASSIGNMENT_STATEMENT).size, `is`(1))
assertThat(node.getDescendants(PlSqlGrammar.ASSIGNMENT_STATEMENT)).hasSize(1)
}

@Test
Expand All @@ -197,7 +194,7 @@ class PlSqlLexerTest {
"\$end\n" +
"end;")

assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT).size, `is`(1))
assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT)).hasSize(1)
}

@Test
Expand All @@ -213,7 +210,7 @@ class PlSqlLexerTest {
"\$end\n" +
"end;")

assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT).size, `is`(1))
assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT)).hasSize(1)
}


Expand All @@ -229,6 +226,6 @@ class PlSqlLexerTest {
"null;\n" +
"end;")

assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT).size, `is`(1))
assertThat(node.getDescendants(PlSqlGrammar.NULL_STATEMENT)).hasSize(1)
}
}

0 comments on commit 5a7dc47

Please sign in to comment.