Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added possibility to strip statement delimiter from parsed statements
- Loading branch information
1 parent
22430f1
commit 47e5a01
Showing
6 changed files
with
131 additions
and
7 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
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
88 changes: 88 additions & 0 deletions
88
...t/java/org/jboss/arquillian/persistence/script/splitter/DefaultStatementSplitterTest.java
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,88 @@ | ||
/* | ||
* Copyright 2017 JBoss by Red Hat. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.arquillian.persistence.script.splitter; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class DefaultStatementSplitterTest { | ||
|
||
@Test | ||
public void should_not_remove_delimiter_if_delimiter_is_not_present() { | ||
// given | ||
String script = "SELECT * FROM TEST"; | ||
|
||
DefaultStatementSplitter splitter = new DefaultStatementSplitter(); | ||
splitter.setTrimStatementDelimiter(true); | ||
|
||
// when | ||
List<String> statements = splitter.splitStatements(script); | ||
|
||
// then | ||
assertThat(statements).containsExactly("SELECT * FROM TEST"); | ||
} | ||
|
||
@Test | ||
public void should_remove_delimiter_on_single_statement() { | ||
// given | ||
String script = "SELECT * FROM TEST;"; | ||
|
||
DefaultStatementSplitter splitter = new DefaultStatementSplitter(); | ||
splitter.setTrimStatementDelimiter(true); | ||
|
||
// when | ||
List<String> statements = splitter.splitStatements(script); | ||
|
||
// then | ||
assertThat(statements).containsExactly("SELECT * FROM TEST"); | ||
} | ||
|
||
@Test | ||
public void should_remove_delimiter_on_multiple_statements() { | ||
// given | ||
String script = "SELECT * FROM TEST1;SELECT * FROM TEST2;"; | ||
|
||
DefaultStatementSplitter splitter = new DefaultStatementSplitter(); | ||
splitter.setTrimStatementDelimiter(true); | ||
|
||
// when | ||
List<String> statements = splitter.splitStatements(script); | ||
|
||
// then | ||
assertThat(statements).containsExactly("SELECT * FROM TEST1", "SELECT * FROM TEST2"); | ||
} | ||
|
||
@Test | ||
public void should_remove_delimiter_on_multiline_statements() { | ||
// given | ||
String script = "SELECT * FROM TEST1;\n" + | ||
"SELECT * FROM TEST2;\n" + | ||
"SELECT * FROM TEST3;\n"; | ||
|
||
DefaultStatementSplitter splitter = new DefaultStatementSplitter(); | ||
splitter.setTrimStatementDelimiter(true); | ||
|
||
// when | ||
List<String> statements = splitter.splitStatements(script); | ||
|
||
// then | ||
assertThat(statements).containsExactly("SELECT * FROM TEST1", "SELECT * FROM TEST2", "SELECT * FROM TEST3"); | ||
} | ||
|
||
} |
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