Added more test assertions

This commit is contained in:
Martijn van Groningen 2013-04-19 22:16:42 +02:00
parent 7ea6cd6888
commit c390f9b1a9
1 changed files with 13 additions and 6 deletions

View File

@ -679,12 +679,15 @@ public class SimpleQueryTests extends AbstractNodesTests {
.setQuery(multiMatchQuery) .setQuery(multiMatchQuery)
.execute().actionGet(); .execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getHits()[0].id(), equalTo("1"));
multiMatchQuery.minimumShouldMatch("30%"); multiMatchQuery.minimumShouldMatch("30%");
searchResponse = client.prepareSearch() searchResponse = client.prepareSearch()
.setQuery(multiMatchQuery) .setQuery(multiMatchQuery)
.execute().actionGet(); .execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].id(), equalTo("1"));
assertThat(searchResponse.getHits().getHits()[1].id(), equalTo("2"));
multiMatchQuery.useDisMax(false); multiMatchQuery.useDisMax(false);
multiMatchQuery.minimumShouldMatch("70%"); multiMatchQuery.minimumShouldMatch("70%");
@ -692,12 +695,15 @@ public class SimpleQueryTests extends AbstractNodesTests {
.setQuery(multiMatchQuery) .setQuery(multiMatchQuery)
.execute().actionGet(); .execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getHits()[0].id(), equalTo("1"));
multiMatchQuery.minimumShouldMatch("30%"); multiMatchQuery.minimumShouldMatch("30%");
searchResponse = client.prepareSearch() searchResponse = client.prepareSearch()
.setQuery(multiMatchQuery) .setQuery(multiMatchQuery)
.execute().actionGet(); .execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].id(), equalTo("1"));
assertThat(searchResponse.getHits().getHits()[1].id(), equalTo("2"));
multiMatchQuery = multiMatchQuery("value1 value2 bar", "field1"); multiMatchQuery = multiMatchQuery("value1 value2 bar", "field1");
multiMatchQuery.minimumShouldMatch("100%"); multiMatchQuery.minimumShouldMatch("100%");
@ -711,7 +717,8 @@ public class SimpleQueryTests extends AbstractNodesTests {
.setQuery(multiMatchQuery) .setQuery(multiMatchQuery)
.execute().actionGet(); .execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
} assertThat(searchResponse.getHits().getHits()[0].id(), equalTo("1"));
}
@Test @Test
public void testFuzzyQueryString() { public void testFuzzyQueryString() {
client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareDelete().execute().actionGet();