-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update search tests: wait for index refresh before call search
- Loading branch information
Tien Nguyen
committed
Jun 19, 2017
1 parent
118e8c8
commit be03f7f
Showing
3 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/test/scala/org/elasticsearch/client/http/ApiEntitiesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.elasticsearch.client.http | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.scala.DefaultScalaModule | ||
import org.elasticsearch.client.http.entities.SearchResponse | ||
import org.scalatest.FunSuite | ||
|
||
/** | ||
* Created by 51103 on 019, 19, 6, 2017. | ||
*/ | ||
class ApiEntitiesTest extends FunSuite { | ||
|
||
val searchResponseStr = | ||
""" | ||
|{ | ||
| "took": 1, | ||
| "timed_out": false, | ||
| "_shards": { | ||
| "total": 1, | ||
| "successful": 1, | ||
| "failed": 0 | ||
| }, | ||
| "hits": { | ||
| "total": 1, | ||
| "max_score": 0.3247595, | ||
| "hits": [ | ||
| { | ||
| "_score": 0.3247595, | ||
| "_type": "doc", | ||
| "_source": { | ||
| "f_suggest": { | ||
| "input": [ | ||
| "Nevermind", | ||
| "Nirvana" | ||
| ], | ||
| "weight": 34 | ||
| }, | ||
| "f_multi": "Foo Bar Baz", | ||
| "f_bool": "true", | ||
| "f1": "foo", | ||
| "f_long": "42", | ||
| "f_date": "1476383971", | ||
| "f3": "foo bar baz", | ||
| "f_nested": { | ||
| "nest1": "nfoo", | ||
| "nest2": "nbar", | ||
| "nest3": 21 | ||
| }, | ||
| "f_object": { | ||
| "sub1": "sfoo", | ||
| "sub2": "sbar", | ||
| "sub3": 19 | ||
| }, | ||
| "f_binary": "VGhpcyBpcyBzb21lIGJpbmFyeSBkYXRhCg==", | ||
| "f_short": "23", | ||
| "f_byte": "7", | ||
| "f_ip": "127.0.0.1", | ||
| "f_geos": { | ||
| "type": "point", | ||
| "coordinates": [ | ||
| -77.03653, | ||
| 38.897676 | ||
| ] | ||
| }, | ||
| "f_float": "1.7", | ||
| "f_geop": "41.12,-71.34", | ||
| "f2": "Bar", | ||
| "f_int": "1293" | ||
| }, | ||
| "_id": "1", | ||
| "_index": "test" | ||
| } | ||
| ] | ||
| } | ||
|} | ||
""".stripMargin | ||
|
||
val objectMapper = new ObjectMapper().registerModule(DefaultScalaModule) | ||
|
||
test("Deserialize SearchResponse from String should return success value") { | ||
|
||
val resp = objectMapper.readValue(searchResponseStr, classOf[SearchResponse]) | ||
assert(resp.hits.total == 1) | ||
assert(!resp.timeOut) | ||
assert(resp.hits.maxScore == 0.3247595) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters