fix line length problems in all classes under o.e.test.rest package
This commit is contained in:
parent
0b5a549305
commit
dd781d410a
|
@ -1263,24 +1263,8 @@
|
|||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]engine[/\\]MockEngineSupport.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]hamcrest[/\\]ElasticsearchAssertions.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]junit[/\\]listeners[/\\]LoggingListener.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]GreaterThanEqualToParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]GreaterThanParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]LessThanOrEqualToParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]LessThanParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]RestTestSuiteParseContext.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]parser[/\\]RestTestSuiteParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]GreaterThanAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]GreaterThanEqualToAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]LengthAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]LessThanAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]LessThanOrEqualToAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]section[/\\]MatchAssertion.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]spec[/\\]RestApiParser.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]support[/\\]FileUtils.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]store[/\\]MockFSDirectoryService.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]store[/\\]MockFSIndexStore.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]test[/\\]FileUtilsTests.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]rest[/\\]test[/\\]RestTestParserTests.java" checks="LineLength" />
|
||||
<suppress files="test[/\\]framework[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]test[/\\]InternalTestClusterTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]common[/\\]cli[/\\]CliTool.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]rest[/\\]action[/\\]admin[/\\]indices[/\\]settings[/\\]RestGetSettingsAction.java" checks="LineLength" />
|
||||
|
|
|
@ -84,7 +84,8 @@ public class ObjectPath {
|
|||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("element was a list, but [" + key + "] was not numeric", e);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new IllegalArgumentException("element was a list with " + list.size() + " elements, but [" + key + "] was out of bounds", e);
|
||||
throw new IllegalArgumentException("element was a list with " + list.size() +
|
||||
" elements, but [" + key + "] was out of bounds", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ public class GreaterThanEqualToParser implements RestTestFragmentParser<GreaterT
|
|||
public GreaterThanEqualToAssertion parse(RestTestSuiteParseContext parseContext) throws IOException, RestTestParseException {
|
||||
Tuple<String,Object> stringObjectTuple = parseContext.parseTuple();
|
||||
if (! (stringObjectTuple.v2() instanceof Comparable) ) {
|
||||
throw new RestTestParseException("gte section can only be used with objects that support natural ordering, found " + stringObjectTuple.v2().getClass().getSimpleName());
|
||||
throw new RestTestParseException("gte section can only be used with objects that support natural ordering, found "
|
||||
+ stringObjectTuple.v2().getClass().getSimpleName());
|
||||
}
|
||||
return new GreaterThanEqualToAssertion(stringObjectTuple.v1(), stringObjectTuple.v2());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ public class GreaterThanParser implements RestTestFragmentParser<GreaterThanAsse
|
|||
public GreaterThanAssertion parse(RestTestSuiteParseContext parseContext) throws IOException, RestTestParseException {
|
||||
Tuple<String,Object> stringObjectTuple = parseContext.parseTuple();
|
||||
if (! (stringObjectTuple.v2() instanceof Comparable) ) {
|
||||
throw new RestTestParseException("gt section can only be used with objects that support natural ordering, found " + stringObjectTuple.v2().getClass().getSimpleName());
|
||||
throw new RestTestParseException("gt section can only be used with objects that support natural ordering, found "
|
||||
+ stringObjectTuple.v2().getClass().getSimpleName());
|
||||
}
|
||||
return new GreaterThanAssertion(stringObjectTuple.v1(), stringObjectTuple.v2());
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ public class LessThanOrEqualToParser implements RestTestFragmentParser<LessThanO
|
|||
public LessThanOrEqualToAssertion parse(RestTestSuiteParseContext parseContext) throws IOException, RestTestParseException {
|
||||
Tuple<String,Object> stringObjectTuple = parseContext.parseTuple();
|
||||
if (! (stringObjectTuple.v2() instanceof Comparable) ) {
|
||||
throw new RestTestParseException("lte section can only be used with objects that support natural ordering, found " + stringObjectTuple.v2().getClass().getSimpleName());
|
||||
throw new RestTestParseException("lte section can only be used with objects that support natural ordering, found "
|
||||
+ stringObjectTuple.v2().getClass().getSimpleName());
|
||||
}
|
||||
return new LessThanOrEqualToAssertion(stringObjectTuple.v1(), stringObjectTuple.v2());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ public class LessThanParser implements RestTestFragmentParser<LessThanAssertion>
|
|||
public LessThanAssertion parse(RestTestSuiteParseContext parseContext) throws IOException, RestTestParseException {
|
||||
Tuple<String,Object> stringObjectTuple = parseContext.parseTuple();
|
||||
if (! (stringObjectTuple.v2() instanceof Comparable) ) {
|
||||
throw new RestTestParseException("lt section can only be used with objects that support natural ordering, found " + stringObjectTuple.v2().getClass().getSimpleName());
|
||||
throw new RestTestParseException("lt section can only be used with objects that support natural ordering, found "
|
||||
+ stringObjectTuple.v2().getClass().getSimpleName());
|
||||
}
|
||||
return new LessThanAssertion(stringObjectTuple.v1(), stringObjectTuple.v2());
|
||||
}
|
||||
|
|
|
@ -158,7 +158,8 @@ public class RestTestSuiteParseContext {
|
|||
token = parser.nextToken();
|
||||
}
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new RestTestParseException("malformed test section: field name expected but found " + token + " at " + parser.getTokenLocation());
|
||||
throw new RestTestParseException("malformed test section: field name expected but found " + token + " at "
|
||||
+ parser.getTokenLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ public class RestTestSuiteParser implements RestTestFragmentParser<RestTestSuite
|
|||
XContentParser parser = parseContext.parser();
|
||||
|
||||
parser.nextToken();
|
||||
assert parser.currentToken() == XContentParser.Token.START_OBJECT : "expected token to be START_OBJECT but was " + parser.currentToken();
|
||||
assert parser.currentToken() == XContentParser.Token.START_OBJECT : "expected token to be START_OBJECT but was "
|
||||
+ parser.currentToken();
|
||||
|
||||
RestTestSuite restTestSuite = new RestTestSuite(parseContext.getApi(), parseContext.getSuiteName());
|
||||
|
||||
|
@ -90,7 +91,8 @@ public class RestTestSuiteParser implements RestTestFragmentParser<RestTestSuite
|
|||
|
||||
TestSection testSection = parseContext.parseTestSection();
|
||||
if (!restTestSuite.addTestSection(testSection)) {
|
||||
throw new RestTestParseException("duplicate test section [" + testSection.getName() + "] found in [" + restTestSuite.getPath() + "]");
|
||||
throw new RestTestParseException("duplicate test section [" + testSection.getName() + "] found in ["
|
||||
+ restTestSuite.getPath() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,10 @@ public class GreaterThanAssertion extends Assertion {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected void doAssert(Object actualValue, Object expectedValue) {
|
||||
logger.trace("assert that [{}] is greater than [{}] (field: [{}])", actualValue, expectedValue, getField());
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])", actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])", expectedValue, instanceOf(Comparable.class));
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",
|
||||
actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])",
|
||||
expectedValue, instanceOf(Comparable.class));
|
||||
try {
|
||||
assertThat(errorMessage(), (Comparable) actualValue, greaterThan((Comparable) expectedValue));
|
||||
} catch (ClassCastException e) {
|
||||
|
|
|
@ -43,8 +43,10 @@ public class GreaterThanEqualToAssertion extends Assertion {
|
|||
@Override
|
||||
protected void doAssert(Object actualValue, Object expectedValue) {
|
||||
logger.trace("assert that [{}] is greater than or equal to [{}] (field: [{}])", actualValue, expectedValue, getField());
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])", actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])", expectedValue, instanceOf(Comparable.class));
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",
|
||||
actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])",
|
||||
expectedValue, instanceOf(Comparable.class));
|
||||
try {
|
||||
assertThat(errorMessage(), (Comparable) actualValue, greaterThanOrEqualTo((Comparable) expectedValue));
|
||||
} catch (ClassCastException e) {
|
||||
|
|
|
@ -44,7 +44,8 @@ public class LengthAssertion extends Assertion {
|
|||
@Override
|
||||
protected void doAssert(Object actualValue, Object expectedValue) {
|
||||
logger.trace("assert that [{}] has length [{}] (field: [{}])", actualValue, expectedValue, getField());
|
||||
assertThat("expected value of [" + getField() + "] is not numeric (got [" + expectedValue.getClass() + "]", expectedValue, instanceOf(Number.class));
|
||||
assertThat("expected value of [" + getField() + "] is not numeric (got [" + expectedValue.getClass() + "]",
|
||||
expectedValue, instanceOf(Number.class));
|
||||
int length = ((Number) expectedValue).intValue();
|
||||
if (actualValue instanceof String) {
|
||||
assertThat(errorMessage(), ((String) actualValue).length(), equalTo(length));
|
||||
|
|
|
@ -44,8 +44,10 @@ public class LessThanAssertion extends Assertion {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected void doAssert(Object actualValue, Object expectedValue) {
|
||||
logger.trace("assert that [{}] is less than [{}] (field: [{}])", actualValue, expectedValue, getField());
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])", actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])", expectedValue, instanceOf(Comparable.class));
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",
|
||||
actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])",
|
||||
expectedValue, instanceOf(Comparable.class));
|
||||
try {
|
||||
assertThat(errorMessage(), (Comparable) actualValue, lessThan((Comparable) expectedValue));
|
||||
} catch (ClassCastException e) {
|
||||
|
|
|
@ -43,8 +43,10 @@ public class LessThanOrEqualToAssertion extends Assertion {
|
|||
@Override
|
||||
protected void doAssert(Object actualValue, Object expectedValue) {
|
||||
logger.trace("assert that [{}] is less than or equal to [{}] (field: [{}])", actualValue, expectedValue, getField());
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])", actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])", expectedValue, instanceOf(Comparable.class));
|
||||
assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",
|
||||
actualValue, instanceOf(Comparable.class));
|
||||
assertThat("expected value of [" + getField() + "] is not comparable (got [" + expectedValue.getClass() + "])",
|
||||
expectedValue, instanceOf(Comparable.class));
|
||||
try {
|
||||
assertThat(errorMessage(), (Comparable) actualValue, lessThanOrEqualTo((Comparable) expectedValue));
|
||||
} catch (ClassCastException e) {
|
||||
|
|
|
@ -55,7 +55,8 @@ public class MatchAssertion extends Assertion {
|
|||
if (expectedValue instanceof String) {
|
||||
String expValue = ((String) expectedValue).trim();
|
||||
if (expValue.length() > 2 && expValue.startsWith("/") && expValue.endsWith("/")) {
|
||||
assertThat("field [" + getField() + "] was expected to be of type String but is an instanceof [" + safeClass(actualValue) + "]", actualValue, instanceOf(String.class));
|
||||
assertThat("field [" + getField() + "] was expected to be of type String but is an instanceof [" +
|
||||
safeClass(actualValue) + "]", actualValue, instanceOf(String.class));
|
||||
String stringValue = (String) actualValue;
|
||||
String regex = expValue.substring(1, expValue.length() - 1);
|
||||
logger.trace("assert that [{}] matches [{}]", stringValue, regex);
|
||||
|
|
|
@ -78,7 +78,8 @@ public final class FileUtils {
|
|||
* Each input path can either be a single file (the .yaml suffix is optional) or a directory.
|
||||
* Each path is looked up in the classpath, or optionally from {@code fileSystem} if its not null.
|
||||
*/
|
||||
public static Map<String, Set<Path>> findYamlSuites(FileSystem fileSystem, String optionalPathPrefix, final String... paths) throws IOException {
|
||||
public static Map<String, Set<Path>> findYamlSuites(FileSystem fileSystem, String optionalPathPrefix, final String... paths)
|
||||
throws IOException {
|
||||
Map<String, Set<Path>> yamlSuites = new HashMap<>();
|
||||
for (String path : paths) {
|
||||
collectFiles(resolveFile(fileSystem, optionalPathPrefix, path, YAML_SUFFIX), YAML_SUFFIX, yamlSuites);
|
||||
|
@ -86,7 +87,8 @@ public final class FileUtils {
|
|||
return yamlSuites;
|
||||
}
|
||||
|
||||
private static Path resolveFile(FileSystem fileSystem, String optionalPathPrefix, String path, String optionalFileSuffix) throws IOException {
|
||||
private static Path resolveFile(FileSystem fileSystem, String optionalPathPrefix, String path, String optionalFileSuffix)
|
||||
throws IOException {
|
||||
if (fileSystem != null) {
|
||||
Path file = findFile(fileSystem, path, optionalFileSuffix);
|
||||
if (!lenientExists(file)) {
|
||||
|
@ -94,7 +96,8 @@ public final class FileUtils {
|
|||
String newPath = optionalPathPrefix + "/" + path;
|
||||
file = findFile(fileSystem, newPath, optionalFileSuffix);
|
||||
if (!lenientExists(file)) {
|
||||
throw new NoSuchFileException("path prefix: " + optionalPathPrefix + ", path: " + path + ", file suffix: " + optionalFileSuffix);
|
||||
throw new NoSuchFileException("path prefix: " + optionalPathPrefix + ", path: " + path + ", file suffix: "
|
||||
+ optionalFileSuffix);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
|
|
|
@ -84,7 +84,8 @@ public class FileUtilsTests extends ESTestCase {
|
|||
assertSingleFile(yamlSuites.get(dir.getFileName().toString()), dir.getFileName().toString(), file.getFileName().toString());
|
||||
|
||||
//load from external file (optional extension)
|
||||
yamlSuites = FileUtils.findYamlSuites(dir.getFileSystem(), "/rest-api-spec/test", dir.resolve("test_loading").toAbsolutePath().toString());
|
||||
yamlSuites = FileUtils.findYamlSuites(dir.getFileSystem(), "/rest-api-spec/test",
|
||||
dir.resolve("test_loading").toAbsolutePath().toString());
|
||||
assertThat(yamlSuites, notNullValue());
|
||||
assertThat(yamlSuites.size(), equalTo(1));
|
||||
assertThat(yamlSuites.containsKey(dir.getFileName().toString()), equalTo(true));
|
||||
|
|
|
@ -115,11 +115,12 @@ public class RestTestParserTests extends ESTestCase {
|
|||
assertThat(restTestSuite.getSetupSection().getDoSections().size(), equalTo(1));
|
||||
assertThat(restTestSuite.getSetupSection().getDoSections().get(0).getApiCallSection().getApi(), equalTo("indices.create"));
|
||||
assertThat(restTestSuite.getSetupSection().getDoSections().get(0).getApiCallSection().getParams().size(), equalTo(1));
|
||||
assertThat(restTestSuite.getSetupSection().getDoSections().get(0).getApiCallSection().getParams().get("index"), equalTo("test_index"));
|
||||
assertThat(restTestSuite.getSetupSection().getDoSections().get(0).getApiCallSection().getParams().get("index"),
|
||||
equalTo("test_index"));
|
||||
} else {
|
||||
assertThat(restTestSuite.getSetupSection().isEmpty(), equalTo(true));
|
||||
}
|
||||
|
||||
|
||||
assertThat(restTestSuite.getTeardownSection(), notNullValue());
|
||||
if (includeTeardown) {
|
||||
assertThat(restTestSuite.getTeardownSection().isEmpty(), equalTo(false));
|
||||
|
@ -154,7 +155,8 @@ public class RestTestParserTests extends ESTestCase {
|
|||
|
||||
assertThat(restTestSuite.getTestSections().get(1).getName(), equalTo("Get type mapping - pre 1.0"));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().isEmpty(), equalTo(false));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getReason(), equalTo("for newer versions the index name is always returned"));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getReason(),
|
||||
equalTo("for newer versions the index name is always returned"));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getLowerVersion(), equalTo(Version.V_2_0_0));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getSkipSection().getUpperVersion(), equalTo(Version.CURRENT));
|
||||
assertThat(restTestSuite.getTestSections().get(1).getExecutableSections().size(), equalTo(3));
|
||||
|
|
Loading…
Reference in New Issue