Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Jun 21, 2023
1 parent 288a99b commit 80bb250
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ElasticsearchTestServer(String... plugins) {
}

public synchronized ElasticsearchTestServer start() {
Version version = Version.VERSION.major() < 8 ? new Version(7,17,5,false) : new Version(8,3,3,false);
Version version = Version.VERSION.major() < 8 ? new Version(7,17,10,false) : new Version(8,3,3,false);

// Note we could use version.major() + "." + version.minor() + "-SNAPSHOT" but plugins won't install on a snapshot version
String esImage = "docker.elastic.co/elasticsearch/elasticsearch:" + version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
package co.elastic.clients.elasticsearch.spec_issues;

import co.elastic.clients.documentation.usage.Product;
import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.ElasticsearchTestServer;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.Refresh;
import co.elastic.clients.elasticsearch._types.Script;
import co.elastic.clients.elasticsearch._types.analysis.LimitTokenCountTokenFilter;
import co.elastic.clients.elasticsearch._types.mapping.Property;
import co.elastic.clients.elasticsearch._types.mapping.RuntimeField;
import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType;
import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse;
import co.elastic.clients.elasticsearch.core.GetResponse;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.search.Suggester;
Expand All @@ -40,12 +43,15 @@
import co.elastic.clients.elasticsearch.snapshot.RestoreResponse;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.util.BinaryData;
import co.elastic.clients.util.ContentType;
import jakarta.json.stream.JsonParser;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;

/**
* Test issues related to the API specifications.
Expand All @@ -54,6 +60,41 @@
*/
public class SpecIssuesTest extends ModelTestCase {

@Test
public void i0575_asyncBinaryData() throws Exception {

ElasticsearchAsyncClient esAsyncClient = ElasticsearchTestServer.global().asyncClient();

String index = "binary-ingestion-test";
String id = "foo-bar";

BinaryData data = BinaryData.of(
("{\"id\":\"27082ce1-d9ab-404e-a810-f2894640edf4\",\"firstName\":\"Jesse\",\"lastName\":\"Pinkman\",\"addresses\":" +
"[{\"street\":\"1001 Central Ave NE\",\"city\":\"Albuquerque\",\"state\":\"NM\",\"zip\":\"87106\"}]}").getBytes(),
ContentType.APPLICATION_JSON
);

esAsyncClient.index(i -> i
.index(index)
.id(id)
.document(data)
.refresh(Refresh.True)
).get();

GetResponse<BinaryData> getResponse = esAsyncClient.get(g -> g
.index(index)
.id(id)
, BinaryData.class
).get();

assertEquals(id, getResponse.id());
assertEquals(
"{\"id\":\"27082ce1-d9ab-404e-a810-f2894640edf4\",\"firstName\":\"Jesse\",\"lastName\":\"Pinkman\",\"addresses\":" +
"[{\"street\":\"1001 Central Ave NE\",\"city\":\"Albuquerque\",\"state\":\"NM\",\"zip\":\"87106\"}]}",
new String(getResponse.source().asByteBuffer().array(), StandardCharsets.UTF_8)
);
}

@Test
public void i0328_charFilter() throws Exception {
// Both mappings and mappings_path are optional
Expand Down

0 comments on commit 80bb250

Please sign in to comment.