Skip to content

Commit e9ea27e

Browse files
authored
[Spotless] Applying Google Code Format for integ-tests #10 (#329)
* Add spotless apply 33 files. Signed-off-by: Mitchell Gale <[email protected]> * Addressed PR comments. Signed-off-by: Mitchell Gale <[email protected]> * Address PR comments. Signed-off-by: Mitchell Gale <[email protected]> * fixing integ test failure. Signed-off-by: Mitchell Gale <[email protected]> --------- Signed-off-by: Mitchell Gale <[email protected]>
1 parent 245c4f8 commit e9ea27e

33 files changed

+1572
-1483
lines changed

integ-test/src/test/java/org/opensearch/sql/correctness/TestConfig.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness;
87

98
import static java.util.stream.Collectors.joining;
@@ -19,11 +18,13 @@
1918
import org.opensearch.sql.legacy.utils.StringUtils;
2019

2120
/**
21+
* <pre>
2222
* Test configuration parse the following information from command line arguments:
2323
* 1) Test schema and data
2424
* 2) Test queries
2525
* 3) OpenSearch connection URL
2626
* 4) Other database connection URLs
27+
* </pre>
2728
*/
2829
public class TestConfig {
2930

@@ -37,9 +38,7 @@ public class TestConfig {
3738

3839
private final String openSearchHostUrl;
3940

40-
/**
41-
* Test against some database rather than OpenSearch via our JDBC driver
42-
*/
41+
/** Test against some database rather than OpenSearch via our JDBC driver */
4342
private final String dbConnectionUrl;
4443

4544
private final Map<String, String> otherDbConnectionNameAndUrls = new HashMap<>();
@@ -75,12 +74,14 @@ public Map<String, String> getOtherDbConnectionNameAndUrls() {
7574

7675
private TestDataSet[] buildDefaultTestDataSet() {
7776
return new TestDataSet[] {
78-
new TestDataSet("opensearch_dashboards_sample_data_flights",
79-
readFile("opensearch_dashboards_sample_data_flights.json"),
80-
readFile("opensearch_dashboards_sample_data_flights.csv")),
81-
new TestDataSet("opensearch_dashboards_sample_data_ecommerce",
82-
readFile("opensearch_dashboards_sample_data_ecommerce.json"),
83-
readFile("opensearch_dashboards_sample_data_ecommerce.csv")),
77+
new TestDataSet(
78+
"opensearch_dashboards_sample_data_flights",
79+
readFile("opensearch_dashboards_sample_data_flights.json"),
80+
readFile("opensearch_dashboards_sample_data_flights.csv")),
81+
new TestDataSet(
82+
"opensearch_dashboards_sample_data_ecommerce",
83+
readFile("opensearch_dashboards_sample_data_ecommerce.json"),
84+
readFile("opensearch_dashboards_sample_data_ecommerce.csv")),
8485
};
8586
}
8687

@@ -118,31 +119,37 @@ private static String readFile(String relativePath) {
118119
@Override
119120
public String toString() {
120121
return "\n=================================\n"
121-
+ "Tested Database : " + openSearchHostUrlToString() + '\n'
122-
+ "Other Databases :\n" + otherDbConnectionInfoToString() + '\n'
123-
+ "Test data set(s) :\n" + testDataSetsToString() + '\n'
124-
+ "Test query set : " + testQuerySet + '\n'
122+
+ "Tested Database : "
123+
+ openSearchHostUrlToString()
124+
+ '\n'
125+
+ "Other Databases :\n"
126+
+ otherDbConnectionInfoToString()
127+
+ '\n'
128+
+ "Test data set(s) :\n"
129+
+ testDataSetsToString()
130+
+ '\n'
131+
+ "Test query set : "
132+
+ testQuerySet
133+
+ '\n'
125134
+ "=================================\n";
126135
}
127136

128137
private String testDataSetsToString() {
129-
return Arrays.stream(testDataSets).
130-
map(TestDataSet::toString).
131-
collect(joining("\n"));
138+
return Arrays.stream(testDataSets).map(TestDataSet::toString).collect(joining("\n"));
132139
}
133140

134141
private String openSearchHostUrlToString() {
135142
if (!dbConnectionUrl.isEmpty()) {
136143
return dbConnectionUrl;
137144
}
138-
return openSearchHostUrl.isEmpty() ? "(Use internal OpenSearch in workspace)" :
139-
openSearchHostUrl;
145+
return openSearchHostUrl.isEmpty()
146+
? "(Use internal OpenSearch in workspace)"
147+
: openSearchHostUrl;
140148
}
141149

142150
private String otherDbConnectionInfoToString() {
143-
return otherDbConnectionNameAndUrls.entrySet().stream().
144-
map(e -> StringUtils.format(" %s = %s", e.getKey(), e.getValue())).
145-
collect(joining("\n"));
151+
return otherDbConnectionNameAndUrls.entrySet().stream()
152+
.map(e -> StringUtils.format(" %s = %s", e.getKey(), e.getValue()))
153+
.collect(joining("\n"));
146154
}
147-
148155
}

integ-test/src/test/java/org/opensearch/sql/correctness/report/SuccessTestCase.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import static org.opensearch.sql.correctness.report.TestCaseReport.TestResult.SUCCESS;
@@ -12,9 +11,7 @@
1211
import lombok.Getter;
1312
import lombok.ToString;
1413

15-
/**
16-
* Report for successful test case result.
17-
*/
14+
/** Report for successful test case result. */
1815
@EqualsAndHashCode(callSuper = true)
1916
@ToString(callSuper = true)
2017
@Getter

integ-test/src/test/java/org/opensearch/sql/correctness/report/TestCaseReport.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import static org.opensearch.sql.correctness.report.TestCaseReport.TestResult.SUCCESS;
@@ -12,22 +11,19 @@
1211
import lombok.Getter;
1312
import lombok.ToString;
1413

15-
/**
16-
* Base class for different test result.
17-
*/
14+
/** Base class for different test result. */
1815
@EqualsAndHashCode
1916
@ToString
2017
public abstract class TestCaseReport {
2118

2219
public enum TestResult {
23-
SUCCESS, FAILURE;
20+
SUCCESS,
21+
FAILURE;
2422
}
2523

26-
@Getter
27-
private final int id;
24+
@Getter private final int id;
2825

29-
@Getter
30-
private final String sql;
26+
@Getter private final String sql;
3127

3228
private final TestResult result;
3329

@@ -40,5 +36,4 @@ public TestCaseReport(int id, String sql, TestResult result) {
4036
public String getResult() {
4137
return result == SUCCESS ? "Success" : "Failed";
4238
}
43-
4439
}

integ-test/src/test/java/org/opensearch/sql/correctness/report/TestReport.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import java.util.ArrayList;
@@ -12,9 +11,7 @@
1211
import lombok.Getter;
1312
import lombok.ToString;
1413

15-
/**
16-
* Test report class to generate JSON report.
17-
*/
14+
/** Test report class to generate JSON report. */
1815
@EqualsAndHashCode
1916
@ToString
2017
@Getter
@@ -37,5 +34,4 @@ public void addTestCase(TestCaseReport testCase) {
3734
summary.addFailure();
3835
}
3936
}
40-
4137
}

integ-test/src/test/java/org/opensearch/sql/correctness/report/TestSummary.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import lombok.EqualsAndHashCode;
109
import lombok.Getter;
1110
import lombok.ToString;
1211

13-
/**
14-
* Test summary section.
15-
*/
12+
/** Test summary section. */
1613
@EqualsAndHashCode
1714
@ToString
1815
@Getter
@@ -33,5 +30,4 @@ public void addFailure() {
3330
failure++;
3431
total++;
3532
}
36-
3733
}

integ-test/src/test/java/org/opensearch/sql/correctness/runner/resultset/Type.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,17 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.runner.resultset;
87

98
import lombok.Data;
109

11-
/**
12-
* Column type in schema
13-
*/
10+
/** Column type in schema */
1411
@Data
1512
public class Type {
1613

17-
/**
18-
* Column name
19-
*/
14+
/** Column name */
2015
private final String name;
2116

22-
/**
23-
* Column type
24-
*/
17+
/** Column type */
2518
private final String type;
26-
2719
}

integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestConfigTest.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.tests;
87

98
import static java.util.Collections.emptyMap;
@@ -18,9 +17,7 @@
1817
import org.junit.Test;
1918
import org.opensearch.sql.correctness.TestConfig;
2019

21-
/**
22-
* Tests for {@link TestConfig}
23-
*/
20+
/** Tests for {@link TestConfig} */
2421
public class TestConfigTest {
2522

2623
@Test
@@ -31,9 +28,7 @@ public void testDefaultConfig() {
3128
config.getOtherDbConnectionNameAndUrls(),
3229
allOf(
3330
hasEntry("H2", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"),
34-
hasEntry("SQLite", "jdbc:sqlite::memory:")
35-
)
36-
);
31+
hasEntry("SQLite", "jdbc:sqlite::memory:")));
3732
}
3833

3934
@Test
@@ -45,18 +40,16 @@ public void testCustomESUrls() {
4540

4641
@Test
4742
public void testCustomDbUrls() {
48-
Map<String, String> args = ImmutableMap.of("otherDbUrls",
49-
"H2=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1,"
50-
+ "Derby=jdbc:derby:memory:myDb;create=true");
43+
Map<String, String> args =
44+
ImmutableMap.of(
45+
"otherDbUrls",
46+
"H2=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1," + "Derby=jdbc:derby:memory:myDb;create=true");
5147

5248
TestConfig config = new TestConfig(args);
5349
assertThat(
5450
config.getOtherDbConnectionNameAndUrls(),
5551
allOf(
5652
hasEntry("H2", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"),
57-
hasEntry("Derby", "jdbc:derby:memory:myDb;create=true")
58-
)
59-
);
53+
hasEntry("Derby", "jdbc:derby:memory:myDb;create=true")));
6054
}
61-
6255
}

integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestDataSetTest.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.tests;
87

98
import static org.hamcrest.MatcherAssert.assertThat;
@@ -13,9 +12,7 @@
1312
import org.junit.Test;
1413
import org.opensearch.sql.correctness.testset.TestDataSet;
1514

16-
/**
17-
* Tests for {@link TestDataSet}
18-
*/
15+
/** Tests for {@link TestDataSet} */
1916
public class TestDataSetTest {
2017

2118
@Test
@@ -40,9 +37,7 @@ public void testDataSetWithSingleColumnData() {
4037
new Object[] {"field"},
4138
new Object[] {"hello"},
4239
new Object[] {"world"},
43-
new Object[] {"123"}
44-
)
45-
);
40+
new Object[] {"123"}));
4641
}
4742

4843
@Test
@@ -61,16 +56,13 @@ public void testDataSetWithMultiColumnsData() {
6156
+ " }\n"
6257
+ "}";
6358

64-
TestDataSet dataSet = new TestDataSet("test", mappings,
65-
"field1,field2\nhello,123\nworld,456");
59+
TestDataSet dataSet = new TestDataSet("test", mappings, "field1,field2\nhello,123\nworld,456");
6660
assertThat(
6761
dataSet.getDataRows(),
6862
contains(
6963
new Object[] {"field1", "field2"},
7064
new Object[] {"hello", 123},
71-
new Object[] {"world", 456}
72-
)
73-
);
65+
new Object[] {"world", 456}));
7466
}
7567

7668
@Test
@@ -86,17 +78,15 @@ public void testDataSetWithEscapedComma() {
8678
+ " }\n"
8779
+ "}";
8880

89-
TestDataSet dataSet = new TestDataSet("test", mappings,
90-
"field\n\"hello,world,123\"\n123\n\"[abc,def,ghi]\"");
81+
TestDataSet dataSet =
82+
new TestDataSet("test", mappings, "field\n\"hello,world,123\"\n123\n\"[abc,def,ghi]\"");
9183
assertThat(
9284
dataSet.getDataRows(),
9385
contains(
9486
new Object[] {"field"},
9587
new Object[] {"hello,world,123"},
9688
new Object[] {"123"},
97-
new Object[] {"[abc,def,ghi]"}
98-
)
99-
);
89+
new Object[] {"[abc,def,ghi]"}));
10090
}
10191

10292
@Test
@@ -115,17 +105,13 @@ public void testDataSetWithNullData() {
115105
+ " }\n"
116106
+ "}";
117107

118-
TestDataSet dataSet = new TestDataSet("test", mappings,
119-
"field1,field2\n,123\nworld,\n,");
108+
TestDataSet dataSet = new TestDataSet("test", mappings, "field1,field2\n,123\nworld,\n,");
120109
assertThat(
121110
dataSet.getDataRows(),
122111
contains(
123112
new Object[] {"field1", "field2"},
124113
new Object[] {null, 123},
125114
new Object[] {"world", null},
126-
new Object[] {null, null}
127-
)
128-
);
115+
new Object[] {null, null}));
129116
}
130-
131117
}

0 commit comments

Comments
 (0)