Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nik9000 committed Sep 12, 2023
1 parent e662516 commit 2f33d55
Showing 1 changed file with 16 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.elasticsearch.action.fieldcaps.FieldCapabilities;
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse;
import org.elasticsearch.common.Strings;
import org.elasticsearch.index.mapper.TimeSeriesParams;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ql.index.IndexResolution;
Expand All @@ -22,7 +21,7 @@

public class EsqlDataTypeRegistryTests extends ESTestCase {
public void testCounter() {
resolve("long", TimeSeriesParams.MetricType.COUNTER, DataTypes.UNSIGNED_LONG);
resolve("long", TimeSeriesParams.MetricType.COUNTER, DataTypes.UNSUPPORTED);
}

public void testGauge() {
Expand All @@ -35,33 +34,25 @@ public void testLong() {

private void resolve(String esTypeName, TimeSeriesParams.MetricType metricType, DataType expected) {
String[] indices = new String[] { "idx-" + randomAlphaOfLength(5) };
FieldCapabilitiesResponse caps = new FieldCapabilitiesResponse(
FieldCapabilities fieldCap = new FieldCapabilities(
randomAlphaOfLength(3),
esTypeName,
false,
true,
true,
false,
metricType,
indices,
Map.of(
"f",
Map.of(
esTypeName,
new FieldCapabilities(
"c",
esTypeName,
false,
true,
true,
false,
metricType,
indices,
Strings.EMPTY_ARRAY,
Strings.EMPTY_ARRAY,
Strings.EMPTY_ARRAY,
Strings.EMPTY_ARRAY,
Map.of()
)
)
)
null,
null,
null,
null,
Map.of()
);
FieldCapabilitiesResponse caps = new FieldCapabilitiesResponse(indices, Map.of(fieldCap.getName(), Map.of(esTypeName, fieldCap)));
IndexResolution resolution = IndexResolver.mergedMappings(EsqlDataTypeRegistry.INSTANCE, "idx-*", caps);

EsField f = resolution.get().mapping().get("f");
EsField f = resolution.get().mapping().get(fieldCap.getName());
assertThat(f.getDataType(), equalTo(expected));
}
}

0 comments on commit 2f33d55

Please sign in to comment.