Search in sources :

Example 6 with XContentLocation

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();
}
Also used : XContentLocation(org.opensearch.common.xcontent.XContentLocation)

Example 7 with XContentLocation

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 + "]"));
}
Also used : XContentLocation(org.opensearch.common.xcontent.XContentLocation) ParsingException(org.opensearch.common.ParsingException)

Example 8 with XContentLocation

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();
}
Also used : XContentLocation(org.opensearch.common.xcontent.XContentLocation)

Example 9 with XContentLocation

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());
}
Also used : XContentLocation(org.opensearch.common.xcontent.XContentLocation)

Example 10 with XContentLocation

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());
}
Also used : XContentLocation(org.opensearch.common.xcontent.XContentLocation)

Aggregations

XContentLocation (org.opensearch.common.xcontent.XContentLocation)27 ParsingException (org.opensearch.common.ParsingException)11 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 NamedObjectNotFoundException (org.opensearch.common.xcontent.NamedObjectNotFoundException)2 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)2 SearchParseException (org.opensearch.search.SearchParseException)2 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 SearchPhaseExecutionException (org.opensearch.action.search.SearchPhaseExecutionException)1 ShardSearchFailure (org.opensearch.action.search.ShardSearchFailure)1 ClusterBlockException (org.opensearch.cluster.block.ClusterBlockException)1 Tuple (org.opensearch.common.collect.Tuple)1 ToXContentObject (org.opensearch.common.xcontent.ToXContentObject)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1 ShardId (org.opensearch.index.shard.ShardId)1