|
23 | 23 | import co.elastic.clients.elasticsearch._types.FieldSort; |
24 | 24 | import co.elastic.clients.elasticsearch._types.FieldValue; |
25 | 25 | import co.elastic.clients.elasticsearch._types.ScriptSource; |
| 26 | +import co.elastic.clients.elasticsearch._types.Time; |
| 27 | +import co.elastic.clients.elasticsearch._types.TimeUnit; |
26 | 28 | import co.elastic.clients.elasticsearch._types.aggregations.TopMetrics; |
27 | 29 | import co.elastic.clients.elasticsearch._types.query_dsl.MatchAllQuery; |
28 | 30 | import co.elastic.clients.elasticsearch.core.MsearchRequest; |
| 31 | +import co.elastic.clients.elasticsearch.core.OpenPointInTimeRequest; |
29 | 32 | import co.elastic.clients.elasticsearch.core.SearchRequest; |
30 | 33 | import co.elastic.clients.elasticsearch.core.SearchResponse; |
31 | 34 | import co.elastic.clients.testkit.ModelTestCase; |
@@ -89,12 +92,12 @@ public void voidClassTDocumentOverload() throws IOException { |
89 | 92 | // nor testing anything, just checking that this compiles |
90 | 93 | ElasticsearchClient client = ElasticsearchClient.of(e -> e.host("http://localhost:9200")); |
91 | 94 |
|
92 | | - SearchResponse<Void> resp = client.search(s -> s,Void.class); |
| 95 | + SearchResponse<Void> resp = client.search(s -> s, Void.class); |
93 | 96 | SearchResponse<Void> respDefault = client.search(s -> s); |
94 | 97 | } |
95 | 98 |
|
96 | 99 | @Test |
97 | | - public void searchRequestBodyOverloads() throws IOException { |
| 100 | + public void searchRequestBodyOverloads() { |
98 | 101 |
|
99 | 102 | // Normal search request |
100 | 103 | SearchRequest searchRequest = SearchRequest.of(b -> b |
@@ -147,4 +150,22 @@ public void searchRequestBodyOverloads() throws IOException { |
147 | 150 | // Assert both variants result in the same serialization |
148 | 151 | assertEquals(scriptSourceStandard.toString(), scriptSourceOverload.toString()); |
149 | 152 | } |
| 153 | + |
| 154 | + @Test |
| 155 | + public void timeOverload() { |
| 156 | + OpenPointInTimeRequest opr = OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(k -> k.time( |
| 157 | + "5s"))); |
| 158 | + OpenPointInTimeRequest opr1 = |
| 159 | + OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(k -> k.time(5, TimeUnit.Seconds))); |
| 160 | + OpenPointInTimeRequest opr2 = |
| 161 | + OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(Time.of(t -> t.time("5s")))); |
| 162 | + OpenPointInTimeRequest opr3 = |
| 163 | + OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(Time.of(t -> t.time(5, |
| 164 | + TimeUnit.Seconds)))); |
| 165 | + |
| 166 | + // Assert all variants result in the same serialization |
| 167 | + assertEquals(opr.toString(), opr1.toString()); |
| 168 | + assertEquals(opr.toString(), opr2.toString()); |
| 169 | + assertEquals(opr.toString(), opr3.toString()); |
| 170 | + } |
150 | 171 | } |
0 commit comments