Skip to content

Commit

Permalink
Remove much ceremony from parsing client yaml test suites (#22311)
Browse files Browse the repository at this point in the history
* Remove a checked exception, replacing it with `ParsingException`.
* Remove all Parser classes for the yaml sections, replacing them with static methods.
* Remove `ClientYamlTestFragmentParser`. Isn't used any more.
* Remove `ClientYamlTestSuiteParseContext`, replacing it with some static utility methods.

I did not rewrite the parsers using `ObjectParser` because I don't think it is worth it right now.
  • Loading branch information
nik9000 authored Dec 22, 2016
1 parent e1b8528 commit f5f2149
Show file tree
Hide file tree
Showing 93 changed files with 1,373 additions and 2,174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public void testExceptionRegistration()
final Path startPath = PathUtils.get(ElasticsearchException.class.getProtectionDomain().getCodeSource().getLocation().toURI())
.resolve("org").resolve("elasticsearch");
final Set<? extends Class<?>> ignore = Sets.newHashSet(
org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException.class,
CancellableThreadsTests.CustomException.class,
org.elasticsearch.rest.BytesRestResponseTests.WithHeadersException.class,
AbstractClientHeadersTestCase.InternalException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public DebClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public IntegTestZipClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate)
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public RpmClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public TarClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public ZipClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;
import java.util.List;
Expand All @@ -36,7 +35,7 @@ public DocsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandi
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -33,7 +32,7 @@ public MatrixStatsClientYamlTestSuiteIT(@Name("yaml")ClientYamlTestCandidate tes
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public IngestCommonClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate t
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public LangExpressionClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public LangMustacheClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate t
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -36,7 +35,7 @@ public LangPainlessClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate t
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public PercolatorClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate tes
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -34,7 +33,7 @@ public ReindexClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCa
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -39,7 +38,7 @@ public Netty4ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCan
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public IcuClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandid
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public KuromojiClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testC
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public PhoneticClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testC
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public SmartCNClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCa
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public StempelClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCa
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public UkrainianClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate test
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public DiscoveryAzureClassicClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCa
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.parser.ClientYamlTestParseException;

import java.io.IOException;

Expand All @@ -35,7 +34,7 @@ public CloudAwsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testC
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, ClientYamlTestParseException {
public static Iterable<Object[]> parameters() throws IOException {
return ESClientYamlSuiteTestCase.createParameters();
}
}
Expand Down
Loading

0 comments on commit f5f2149

Please sign in to comment.