26
26
import org .junit .ClassRule ;
27
27
import org .junit .Test ;
28
28
import org .junit .runner .RunWith ;
29
+
29
30
import org .springframework .beans .factory .annotation .Autowired ;
30
31
import org .springframework .boot .test .context .SpringBootTest ;
31
32
import org .springframework .data .elasticsearch .core .ReactiveElasticsearchOperations ;
33
+ import org .springframework .data .elasticsearch .core .SearchHit ;
32
34
import org .springframework .data .elasticsearch .core .query .Criteria ;
33
35
import org .springframework .data .elasticsearch .core .query .CriteriaQuery ;
34
- import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
35
36
import org .springframework .test .context .junit4 .SpringRunner ;
36
37
37
38
/**
@@ -57,19 +58,19 @@ public void textSearch() {
57
58
CriteriaQuery query = new CriteriaQuery (
58
59
new Criteria ("keywords" ).contains (expectedWord ).and ("date" ).greaterThanEqual (expectedDate ));
59
60
60
- operations .find (query , Conference .class ) //
61
+ operations .search (query , Conference .class ) //
61
62
.as (StepVerifier ::create ) //
62
63
.consumeNextWith (it -> verify (it , expectedWord , expectedDate )) //
63
64
.consumeNextWith (it -> verify (it , expectedWord , expectedDate )) //
64
65
.consumeNextWith (it -> verify (it , expectedWord , expectedDate )) //
65
66
.verifyComplete ();
66
67
}
67
68
68
- void verify (Conference it , String expectedWord , String expectedDate ) {
69
+ void verify (SearchHit < Conference > hit , String expectedWord , String expectedDate ) {
69
70
70
- assertThat (it .getKeywords ()).contains (expectedWord );
71
+ assertThat (hit . getContent () .getKeywords ()).contains (expectedWord );
71
72
try {
72
- assertThat (format .parse (it .getDate ())).isAfter (format .parse (expectedDate ));
73
+ assertThat (format .parse (hit . getContent () .getDate ())).isAfter (format .parse (expectedDate ));
73
74
} catch (ParseException e ) {
74
75
fail ("o_O" , e );
75
76
}
0 commit comments