use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class ClientYamlTestSuiteTests method testAddingDoWithNodeSelectorWithSkip.
public void testAddingDoWithNodeSelectorWithSkip() {
int lineNumber = between(1, 10000);
SkipSection skipSection = new SkipSection(null, singletonList("node_selector"), null);
DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
ApiCallSection apiCall = new ApiCallSection("test");
apiCall.setNodeSelector(NodeSelector.SKIP_DEDICATED_MASTERS);
doSection.setApiCallSection(apiCall);
createTestSuite(skipSection, doSection).validate();
}
use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class ClientYamlTestSuiteTests method testAddingDoWithAllowedWarningWithoutSkipAllowedWarnings.
public void testAddingDoWithAllowedWarningWithoutSkipAllowedWarnings() {
int lineNumber = between(1, 10000);
DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
doSection.setAllowedWarningHeaders(singletonList("foo"));
doSection.setApiCallSection(new ApiCallSection("test"));
ClientYamlTestSuite testSuite = createTestSuite(SkipSection.EMPTY, doSection);
Exception e = expectThrows(IllegalArgumentException.class, testSuite::validate);
assertThat(e.getMessage(), containsString("api/name:\nattempted to add a [do] with a [allowed_warnings] " + "section without a corresponding [\"skip\": \"features\": \"allowed_warnings\"] so runners that do not " + "support the [allowed_warnings] section can skip the test at line [" + lineNumber + "]"));
}
use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class ClientYamlTestSuiteTests method testAddingContainsWithSkip.
public void testAddingContainsWithSkip() {
int lineNumber = between(1, 10000);
SkipSection skipSection = new SkipSection(null, singletonList("contains"), null);
ContainsAssertion containsAssertion = new ContainsAssertion(new XContentLocation(lineNumber, 0), randomAlphaOfLength(randomIntBetween(3, 30)), randomDouble());
createTestSuite(skipSection, containsAssertion).validate();
}
use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class ContainsAssertion method parse.
public static ContainsAssertion parse(XContentParser parser) throws IOException {
XContentLocation location = parser.getTokenLocation();
Tuple<String, Object> stringObjectTuple = ParserUtils.parseTuple(parser);
return new ContainsAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class LessThanAssertion method parse.
public static LessThanAssertion parse(XContentParser parser) throws IOException {
XContentLocation location = parser.getTokenLocation();
Tuple<String, Object> stringObjectTuple = ParserUtils.parseTuple(parser);
if (false == stringObjectTuple.v2() instanceof Comparable) {
throw new IllegalArgumentException("lt section can only be used with objects that support natural ordering, found " + stringObjectTuple.v2().getClass().getSimpleName());
}
return new LessThanAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
Aggregations