DATAES-754 - Completion field deserialization is failing due to class cast error.

Original PR: #399
This commit is contained in:
Peter-Josef Meisch 2020-02-26 22:34:44 +01:00 committed by GitHub
parent bf51de3805
commit 251adc1eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package org.springframework.data.elasticsearch.core.completion;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -23,6 +24,11 @@ public class Completion {
this.input = input; this.input = input;
} }
@PersistenceConstructor
public Completion(List<String> input) {
this.input = input.toArray(new String[0]);
}
public String[] getInput() { public String[] getInput() {
return input; return input;
} }

View File

@ -87,7 +87,8 @@ public class ElasticsearchTemplateCompletionTests {
indexQueries.add(new CompletionEntityBuilder("4").name("Artur Konczak").suggest(new String[] { "Artur", "Konczak" }) indexQueries.add(new CompletionEntityBuilder("4").name("Artur Konczak").suggest(new String[] { "Artur", "Konczak" })
.buildIndex()); .buildIndex());
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-core-completion").withTypes("completion-type")); IndexCoordinates index = IndexCoordinates.of("test-index-core-completion");
operations.bulkIndex(indexQueries, index);
operations.indexOps(CompletionEntity.class).refresh(); operations.indexOps(CompletionEntity.class).refresh();
} }
@ -151,6 +152,13 @@ public class ElasticsearchTemplateCompletionTests {
assertThat(options.get(1).getText().string()).isIn("Marchand", "Mohsin"); assertThat(options.get(1).getText().string()).isIn("Marchand", "Mohsin");
} }
@Test // DATAES-754
void shouldRetrieveEntityWithCompletion() {
loadCompletionObjectEntities();
IndexCoordinates index = IndexCoordinates.of("test-index-core-completion");
operations.get("1", CompletionEntity.class, index);
}
@Test @Test
public void shouldFindSuggestionsForGivenCriteriaQueryUsingAnnotatedCompletionEntity() { public void shouldFindSuggestionsForGivenCriteriaQueryUsingAnnotatedCompletionEntity() {