|
25 | 25 | import co.elastic.clients.elasticsearch._types.mapping.TextProperty; |
26 | 26 | import co.elastic.clients.elasticsearch._types.query_dsl.Query; |
27 | 27 | import co.elastic.clients.elasticsearch._types.query_dsl.TermQuery; |
| 28 | +import co.elastic.clients.elasticsearch.cluster.GetComponentTemplateResponse; |
28 | 29 | import co.elastic.clients.elasticsearch.core.IndexRequest; |
29 | 30 | import co.elastic.clients.elasticsearch.core.SearchResponse; |
30 | 31 | import co.elastic.clients.elasticsearch.indices.PutIndicesSettingsRequest; |
@@ -185,5 +186,69 @@ public void testExternalTaggedUnion() { |
185 | 186 | .withJson(new StringReader("{\"id\": \"foo\"}"))); |
186 | 187 | assertTrue(!withStoredScript.id().isEmpty()); |
187 | 188 | } |
| 189 | + |
| 190 | + @Test |
| 191 | + public void testBooleanEnum() { |
| 192 | + |
| 193 | + String templateJsonBooleanSubobject = """ |
| 194 | + { |
| 195 | + "component_templates": [ |
| 196 | + { |
| 197 | + "name": "test-template", |
| 198 | + "component_template": { |
| 199 | + "template": { |
| 200 | + "mappings": { |
| 201 | + "properties": { |
| 202 | + "document": { |
| 203 | + "subobjects": false, |
| 204 | + "properties": { |
| 205 | + "body.size": { |
| 206 | + "type": "integer" |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | + } |
| 215 | + ] |
| 216 | + } |
| 217 | + """; |
| 218 | + |
| 219 | + String templateJsonStringSubobject = """ |
| 220 | + { |
| 221 | + "component_templates": [ |
| 222 | + { |
| 223 | + "name": "test-template", |
| 224 | + "component_template": { |
| 225 | + "template": { |
| 226 | + "mappings": { |
| 227 | + "properties": { |
| 228 | + "document": { |
| 229 | + "subobjects": "false", |
| 230 | + "properties": { |
| 231 | + "body.size": { |
| 232 | + "type": "integer" |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | + } |
| 237 | + } |
| 238 | + } |
| 239 | + } |
| 240 | + } |
| 241 | + ] |
| 242 | + } |
| 243 | + """; |
| 244 | + |
| 245 | + GetComponentTemplateResponse respBool = GetComponentTemplateResponse.of(t -> t |
| 246 | + .withJson(new StringReader(templateJsonBooleanSubobject))); |
| 247 | + GetComponentTemplateResponse respString = GetComponentTemplateResponse.of(t -> t |
| 248 | + .withJson(new StringReader(templateJsonStringSubobject))); |
| 249 | + |
| 250 | + // Asserting that both gets deserialized in the same way |
| 251 | + assertEquals(respBool.toString(), respString.toString()); |
| 252 | + } |
188 | 253 | } |
189 | 254 |
|
0 commit comments