use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestTableTests method testRowOutOfBounds.
public void testRowOutOfBounds() {
Table table = new Table();
table.startHeaders();
table.addCell("compare");
table.endHeaders();
RestTable.TableIndexComparator comparator = new RestTable.TableIndexComparator(table, Collections.singletonList(new RestTable.ColumnOrderElement("compare", false)));
Error e = expectThrows(AssertionError.class, () -> {
comparator.compare(0, 1);
});
assertEquals("Invalid comparison of indices (0, 1): Table has 0 rows.", e.getMessage());
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class RestTableTests method testAliasSort.
public void testAliasSort() {
Table table = new Table();
table.startHeaders();
table.addCell("compare", "alias:c;");
table.endHeaders();
List<Integer> comparisonList = Arrays.asList(3, 1, 2);
for (int i = 0; i < comparisonList.size(); i++) {
table.startRow();
table.addCell(comparisonList.get(i));
table.endRow();
}
restRequest.params().put("s", "c");
List<Integer> rowOrder = RestTable.getRowOrder(table, restRequest);
assertEquals(Arrays.asList(1, 2, 0), rowOrder);
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class ExampleCatAction method getTableWithHeader.
@Override
protected Table getTableWithHeader(RestRequest request) {
final Table table = new Table();
table.startHeaders();
table.addCell("test", "desc:test");
table.endHeaders();
return table;
}
use of org.elasticsearch.common.Table in project elasticsearch by elastic.
the class ExampleCatAction method doCatRequest.
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
Table table = getTableWithHeader(request);
table.startRow();
table.addCell(config.getTestConfig());
table.endRow();
return channel -> {
try {
channel.sendResponse(RestTable.buildResponse(table, channel));
} catch (final Exception e) {
channel.sendResponse(new BytesRestResponse(channel, e));
}
};
}
Aggregations