use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class ClientYamlTestSuiteTests method testAddingDoWithWarningWithoutSkipWarnings.
public void testAddingDoWithWarningWithoutSkipWarnings() {
int lineNumber = between(1, 10000);
DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
doSection.setExpectedWarningHeaders(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 [warnings] section without a corresponding " + "[\"skip\": \"features\": \"warnings\"] so runners that do not support the [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 testAddingContainsWithoutSkipContains.
public void testAddingContainsWithoutSkipContains() {
int lineNumber = between(1, 10000);
ContainsAssertion containsAssertion = new ContainsAssertion(new XContentLocation(lineNumber, 0), randomAlphaOfLength(randomIntBetween(3, 30)), randomDouble());
ClientYamlTestSuite testSuite = createTestSuite(SkipSection.EMPTY, containsAssertion);
Exception e = expectThrows(IllegalArgumentException.class, testSuite::validate);
assertThat(e.getMessage(), containsString("api/name:\nattempted to add a [contains] assertion without a corresponding " + "[\"skip\": \"features\": \"contains\"] so runners that do not support the [contains] assertion " + "can skip the test at line [" + lineNumber + "]"));
}
use of org.opensearch.common.xcontent.XContentLocation in project OpenSearch by opensearch-project.
the class MatchAssertionTests method testNullInMap.
public void testNullInMap() {
XContentLocation xContentLocation = new XContentLocation(0, 0);
MatchAssertion matchAssertion = new MatchAssertion(xContentLocation, "field", singletonMap("a", null));
matchAssertion.doAssert(singletonMap("a", null), matchAssertion.getExpectedValue());
AssertionError e = expectThrows(AssertionError.class, () -> matchAssertion.doAssert(emptyMap(), matchAssertion.getExpectedValue()));
assertThat(e.getMessage(), containsString("expected [null] but not found"));
}
Aggregations