[TEST] make CountRequestBuilder#toString and SearchRequestBuilder#toString tests non platform dependent

This commit is contained in:
javanna 2015-04-28 14:24:51 +02:00 committed by Luca Cavanna
parent 54f2a91aff
commit b8caa52e7c
2 changed files with 4 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
public class CountRequestBuilderTests extends ElasticsearchTestCase { public class CountRequestBuilderTests extends ElasticsearchTestCase {
@ -72,7 +73,7 @@ public class CountRequestBuilderTests extends ElasticsearchTestCase {
CountRequestBuilder countRequestBuilder = new CountRequestBuilder(client); CountRequestBuilder countRequestBuilder = new CountRequestBuilder(client);
String query = "{ \"match_all\" : {} }"; String query = "{ \"match_all\" : {} }";
countRequestBuilder.setQuery(new BytesArray(query)); countRequestBuilder.setQuery(new BytesArray(query));
assertThat(countRequestBuilder.toString(), equalTo("{\n \"query\":{ \"match_all\" : {} }\n}")); assertThat(countRequestBuilder.toString(), containsString("\"query\":{ \"match_all\" : {} }"));
} }
@Test @Test

View File

@ -34,6 +34,7 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
public class SearchRequestBuilderTests extends ElasticsearchTestCase { public class SearchRequestBuilderTests extends ElasticsearchTestCase {
@ -83,7 +84,7 @@ public class SearchRequestBuilderTests extends ElasticsearchTestCase {
SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client); SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client);
String query = "{ \"match_all\" : {} }"; String query = "{ \"match_all\" : {} }";
searchRequestBuilder.setQuery(query); searchRequestBuilder.setQuery(query);
assertThat(searchRequestBuilder.toString(), equalTo("{\n \"query\":{ \"match_all\" : {} }\n}")); assertThat(searchRequestBuilder.toString(), containsString("\"query\":{ \"match_all\" : {} }"));
} }
@Test @Test