use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.
the class HighlightBuilderTests method init.
/**
* setup for the whole base test class
*/
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.
the class CollapseBuilderTests method init.
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.
the class OpenSearchClientYamlSuiteTestCase method createParameters.
/**
* Create parameters for this parameterized test.
*/
public static Iterable<Object[]> createParameters(NamedXContentRegistry executeableSectionRegistry) throws Exception {
// default to all tests under the test root
String[] paths = resolvePathsProperty(REST_TESTS_SUITE, "");
Map<String, Set<Path>> yamlSuites = loadSuites(paths);
List<ClientYamlTestSuite> suites = new ArrayList<>();
IllegalArgumentException validationException = null;
// yaml suites are grouped by directory (effectively by api)
for (String api : yamlSuites.keySet()) {
List<Path> yamlFiles = new ArrayList<>(yamlSuites.get(api));
for (Path yamlFile : yamlFiles) {
ClientYamlTestSuite suite = ClientYamlTestSuite.parse(executeableSectionRegistry, api, yamlFile);
suites.add(suite);
try {
suite.validate();
} catch (IllegalArgumentException e) {
if (validationException == null) {
validationException = new IllegalArgumentException("Validation errors for the following test suites:\n- " + e.getMessage());
} else {
String previousMessage = validationException.getMessage();
Throwable[] suppressed = validationException.getSuppressed();
validationException = new IllegalArgumentException(previousMessage + "\n- " + e.getMessage());
for (Throwable t : suppressed) {
validationException.addSuppressed(t);
}
}
validationException.addSuppressed(e);
}
}
}
if (validationException != null) {
throw validationException;
}
List<Object[]> tests = new ArrayList<>();
for (ClientYamlTestSuite yamlTestSuite : suites) {
for (ClientYamlTestSection testSection : yamlTestSuite.getTestSections()) {
tests.add(new Object[] { new ClientYamlTestCandidate(yamlTestSuite, testSection) });
}
}
// sort the candidates so they will always be in the same order before being shuffled, for repeatability
tests.sort(Comparator.comparing(o -> ((ClientYamlTestCandidate) o[0]).getTestPath()));
return tests;
}
use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.
the class AggregatorFactoriesBuilderTests method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
// register aggregations as NamedWriteable
SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
namedXContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.
the class AggregatorFactoriesTests method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, emptyList()).getNamedXContents());
}
Aggregations