Skip to content

Commit 7f39084

Browse files
committed
Polishing.
(cherry picked from commit a82952b) (cherry picked from commit 4628908)
1 parent 868a994 commit 7f39084

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

src/main/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ private static PhraseSuggestion getPhraseSuggestion(String name, List<Suggestion
192192
var phraseSuggestOptions = phraseSuggest.options();
193193
List<PhraseSuggestion.Entry.Option> options = new ArrayList<>();
194194
phraseSuggestOptions.forEach(optionES -> options
195-
.add(new PhraseSuggestion.Entry.Option(optionES.text(), optionES.highlighted(), optionES.score(), optionES.collateMatch())));
195+
.add(new PhraseSuggestion.Entry.Option(optionES.text(), optionES.highlighted(), optionES.score(),
196+
optionES.collateMatch())));
196197
entries.add(new PhraseSuggestion.Entry(phraseSuggest.text(), phraseSuggest.offset(), phraseSuggest.length(),
197198
options, null));
198199
});

src/test/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilderUnitTests.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
*/
1616
package org.springframework.data.elasticsearch.client.elc;
1717

18+
import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
19+
import co.elastic.clients.elasticsearch.core.search.Suggestion;
20+
import co.elastic.clients.elasticsearch.core.search.TotalHitsRelation;
21+
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
22+
1823
import java.util.ArrayList;
1924
import java.util.List;
2025

@@ -26,11 +31,6 @@
2631
import com.google.common.collect.ImmutableList;
2732
import com.google.common.collect.ImmutableMap;
2833

29-
import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
30-
import co.elastic.clients.elasticsearch.core.search.Suggestion;
31-
import co.elastic.clients.elasticsearch.core.search.TotalHitsRelation;
32-
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
33-
3434
/**
3535
* Tests for the factory class to create {@link SearchDocumentResponse} instances.
3636
*
@@ -41,39 +41,40 @@ class SearchDocumentResponseBuilderUnitTests {
4141

4242
private JacksonJsonpMapper jsonpMapper = new JacksonJsonpMapper();
4343

44-
@Test // GH-2681
44+
@Test // #2681
4545
void shouldGetPhraseSuggestion() throws JSONException {
4646
// arrange
4747
final var hitsMetadata = new HitsMetadata.Builder<EntityAsMap>()
4848
.total(total -> total
49-
.value(0)
50-
.relation(TotalHitsRelation.Eq))
49+
.value(0)
50+
.relation(TotalHitsRelation.Eq))
5151
.hits(new ArrayList<>())
5252
.build();
5353

5454
final var suggestionTest = new Suggestion.Builder<EntityAsMap>()
55-
.phrase(phrase -> phrase
56-
.text("National")
57-
.offset(0)
58-
.length(8)
59-
.options(option -> option
60-
.text("nations")
61-
.highlighted("highlighted-nations")
62-
.score(0.11480146)
63-
.collateMatch(false))
64-
.options(option -> option
65-
.text("national")
66-
.highlighted("highlighted-national")
67-
.score( 0.08063514)
68-
.collateMatch(false)))
69-
.build();
70-
71-
final var sortProperties = ImmutableMap.<String, List<Suggestion<EntityAsMap>>>builder()
72-
.put("suggestionTest", ImmutableList.of(suggestionTest))
73-
.build();
55+
.phrase(phrase -> phrase
56+
.text("National")
57+
.offset(0)
58+
.length(8)
59+
.options(option -> option
60+
.text("nations")
61+
.highlighted("highlighted-nations")
62+
.score(0.11480146)
63+
.collateMatch(false))
64+
.options(option -> option
65+
.text("national")
66+
.highlighted("highlighted-national")
67+
.score(0.08063514)
68+
.collateMatch(false)))
69+
.build();
70+
71+
final var sortProperties = ImmutableMap.<String, List<Suggestion<EntityAsMap>>> builder()
72+
.put("suggestionTest", ImmutableList.of(suggestionTest))
73+
.build();
7474

7575
// act
76-
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, sortProperties, null, jsonpMapper);
76+
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, sortProperties, null,
77+
jsonpMapper);
7778

7879
// assert
7980
SoftAssertions softly = new SoftAssertions();

0 commit comments

Comments
 (0)