Skip to content

Commit c4bbe4f

Browse files
Add JaveDocs to QueryVerification
1 parent 69593cd commit c4bbe4f

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/test/java/org/javawebstack/orm/test/shared/verification/QueryVerification.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import static org.junit.jupiter.api.Assertions.assertTrue;
99
import static org.junit.jupiter.api.Assertions.fail;
1010

11+
/**
12+
* The QueryVerification class wraps an JWS Query Object and provides assertion methods regarding the raw query string.
13+
* For entered values it will however use a ? as they are retrieved from the prepared statement phase. No validation beyond the
14+
* assertions are made.
15+
*/
1116
public class QueryVerification {
1217

1318
HashSet<String> sectionNames;
@@ -20,22 +25,37 @@ public QueryVerification(Query<?> query) {
2025

2126
}
2227

23-
public void assertSectionContains(String sectionName, String containedSubstring) {
24-
this.assertSectionContains(sectionName, containedSubstring, 0);
28+
/**
29+
* Asserts that in the first occurring section of a given top level keyword, the given string is contained.
30+
* This method uses the String.contains method internally and is therefore case sensitive.
31+
*
32+
* @param topLevelKeyword The top level keyword that prefaces the section.
33+
* @param containedSubstring The substring which should be contained in the first section of the given type.
34+
*/
35+
public void assertSectionContains(String topLevelKeyword, String containedSubstring) {
36+
this.assertSectionContains(topLevelKeyword, containedSubstring, 0);
2537
}
2638

27-
public void assertSectionContains(String sectionName, String containedSubstring, int sectionIndex) {
39+
/**
40+
* Asserts that in the i-th occurring section of a given top level keyword, the given string is contained.
41+
* This method uses the String.contains method internally and is therefore case sensitive.
42+
*
43+
* @param topLevelKeyword The top level keyword that prefaces the section.
44+
* @param containedSubstring The substring which should be contained in the first section of the given type.
45+
* @param sectionIndex The index of the section to be checked, thusly 0 refers to the first occurrence etc.
46+
*/
47+
public void assertSectionContains(String topLevelKeyword, String containedSubstring, int sectionIndex) {
2848
String sectionString;
2949

3050
try {
3151
sectionString = new QueryStringUtil(this.query.getQueryString().getQuery())
32-
.getTopLevelSectionsByKeyword(sectionName)
52+
.getTopLevelSectionsByKeyword(topLevelKeyword)
3353
.get(sectionIndex);
3454
} catch (IndexOutOfBoundsException ignored) {
3555
fail(String.format(
3656
"A top level section of type %s and index %d was tested but only %d sections of that type existed.",
3757
sectionIndex,
38-
sectionName,
58+
topLevelKeyword,
3959
sectionIndex + 1
4060
));
4161

@@ -44,7 +64,7 @@ public void assertSectionContains(String sectionName, String containedSubstring,
4464

4565
assertTrue(
4666
sectionString.contains(containedSubstring),
47-
String.format("The occurrence of index %d of %s section of the query did not contain a substring %s but looked like this: %s. Note that the match is case-sensitive.", sectionIndex, sectionName, containedSubstring, sectionString)
67+
String.format("The occurrence of index %d of %s section of the query did not contain a substring %s but looked like this: %s. Note that the match is case-sensitive.", sectionIndex, topLevelKeyword, containedSubstring, sectionString)
4868
);
4969
}
5070

0 commit comments

Comments
 (0)