public class ElasticsearchAssertions
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ElasticsearchAssertions.ExceptionWrapper |
Constructor and Description |
---|
ElasticsearchAssertions() |
Modifier and Type | Method and Description |
---|---|
static void |
assertAcked(AcknowledgedRequestBuilder<?,?,?> builder) |
static void |
assertAcked(AcknowledgedResponse response) |
static void |
assertAcked(CreateIndexResponse response)
Assert that an index creation was fully acknowledged, meaning that both the index creation cluster
state update was successful and that the requisite number of shard copies were started before returning.
|
static void |
assertAcked(DeleteIndexRequestBuilder builder) |
static void |
assertAcked(DeleteIndexResponse response) |
static void |
assertAliasesExist(AliasesExistResponse aliasesExistResponse)
Assert that aliases exist
|
static void |
assertAliasesMissing(AliasesExistResponse aliasesExistResponse)
Assert that aliases are missing
|
static void |
assertAllSuccessful(BroadcastResponse response) |
static void |
assertAllSuccessful(SearchResponse response) |
static void |
assertBlocked(ActionRequestBuilder builder)
Executes the request and fails if the request has not been blocked.
|
static void |
assertBlocked(ActionRequestBuilder builder,
ClusterBlock expectedBlock)
Executes the request and fails if the request has not been blocked by a specific
ClusterBlock . |
static void |
assertBlocked(BroadcastResponse replicatedBroadcastResponse)
Checks that all shard requests of a replicated broadcast request failed due to a cluster block
|
static <T extends Query> |
assertBooleanSubQuery(Query query,
java.lang.Class<T> subqueryType,
int i) |
static void |
assertDirectoryExists(java.nio.file.Path dir)
Check if a directory exists
|
static <T extends Query> |
assertDisjunctionSubQuery(Query query,
java.lang.Class<T> subqueryType,
int i) |
static void |
assertExists(GetResponse response) |
static void |
assertFailures(SearchRequestBuilder searchRequestBuilder,
RestStatus restStatus,
org.hamcrest.Matcher<java.lang.String> reasonMatcher) |
static void |
assertFailures(SearchResponse searchResponse) |
static void |
assertFifthHit(SearchResponse searchResponse,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertFileExists(java.nio.file.Path file)
Check if a file exists
|
static void |
assertFileNotExists(java.nio.file.Path file)
Check if a file does not exist
|
static void |
assertFirstHit(SearchResponse searchResponse,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertFourthHit(SearchResponse searchResponse,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertHighlight(SearchHit hit,
java.lang.String field,
int fragment,
int totalFragments,
org.hamcrest.Matcher<java.lang.String> matcher) |
static void |
assertHighlight(SearchHit hit,
java.lang.String field,
int fragment,
org.hamcrest.Matcher<java.lang.String> matcher) |
static void |
assertHighlight(SearchResponse resp,
int hit,
java.lang.String field,
int fragment,
int totalFragments,
org.hamcrest.Matcher<java.lang.String> matcher) |
static void |
assertHighlight(SearchResponse resp,
int hit,
java.lang.String field,
int fragment,
org.hamcrest.Matcher<java.lang.String> matcher) |
static void |
assertHitCount(SearchResponse countResponse,
long expectedHitCount) |
static void |
assertIndexTemplateExists(GetIndexTemplatesResponse templatesResponse,
java.lang.String name)
Assert that an index template exists
|
static void |
assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse,
java.lang.String name)
Assert that an index template is missing
|
static void |
assertNoFailures(BroadcastResponse response) |
static void |
assertNoFailures(BulkResponse response) |
static void |
assertNoFailures(SearchResponse searchResponse) |
static void |
assertNoSearchHits(SearchResponse searchResponse) |
static void |
assertNotHighlighted(SearchResponse resp,
int hit,
java.lang.String field) |
static void |
assertNoTimeout(ClusterHealthRequestBuilder requestBuilder) |
static void |
assertNoTimeout(ClusterHealthResponse response) |
static void |
assertOrderedSearchHits(SearchResponse searchResponse,
java.lang.String... ids) |
static void |
assertSearchHit(SearchHit searchHit,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertSearchHit(SearchResponse searchResponse,
int number,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertSearchHits(SearchResponse searchResponse,
java.lang.String... ids) |
static SearchResponse |
assertSearchResponse(SearchRequestBuilder request)
Applies basic assertions on the SearchResponse.
|
static SearchResponse |
assertSearchResponse(SearchResponse response)
Applies basic assertions on the SearchResponse.
|
static void |
assertSecondHit(SearchResponse searchResponse,
org.hamcrest.Matcher<SearchHit> matcher) |
static void |
assertSortValues(SearchResponse searchResponse,
java.lang.Object[]... sortValues) |
static void |
assertSuggestion(Suggest searchSuggest,
int entry,
int ord,
java.lang.String key,
java.lang.String text) |
static void |
assertSuggestion(Suggest searchSuggest,
int entry,
java.lang.String key,
int size,
java.lang.String... text)
Assert suggestion returns size suggestions and the first are the provided
text.
|
static void |
assertSuggestion(Suggest searchSuggest,
int entry,
java.lang.String key,
java.lang.String... text)
Assert suggestion returns exactly the provided text.
|
static void |
assertSuggestionPhraseCollateMatchExists(Suggest searchSuggest,
java.lang.String key,
int numberOfPhraseExists) |
static void |
assertSuggestionSize(Suggest searchSuggest,
int entry,
int size,
java.lang.String key) |
static void |
assertThirdHit(SearchResponse searchResponse,
org.hamcrest.Matcher<SearchHit> matcher) |
static <E extends java.lang.Throwable> |
assertThrows(ActionFuture future,
java.lang.Class<E> exceptionClass)
Run future.actionGet() and check that it throws an exception of the right type
|
static <E extends java.lang.Throwable> |
assertThrows(ActionFuture future,
java.lang.Class<E> exceptionClass,
RestStatus status)
Run future.actionGet() and check that it throws an exception of the right type, with a given
RestStatus |
static <E extends java.lang.Throwable> |
assertThrows(ActionFuture future,
java.lang.Class<E> exceptionClass,
RestStatus status,
java.lang.String extraInfo)
Run future.actionGet() and check that it throws an exception of the right type, optionally checking the exception's rest status
|
static <E extends java.lang.Throwable> |
assertThrows(ActionFuture future,
java.lang.Class<E> exceptionClass,
java.lang.String extraInfo)
Run future.actionGet() and check that it throws an exception of the right type
|
static <E extends java.lang.Throwable> |
assertThrows(ActionFuture future,
RestStatus status) |
static void |
assertThrows(ActionFuture future,
RestStatus status,
java.lang.String extraInfo) |
static <E extends java.lang.Throwable> |
assertThrows(ActionRequestBuilder<?,?,?> builder,
java.lang.Class<E> exceptionClass)
Run the request from a given builder and check that it throws an exception of the right type
|
static <E extends java.lang.Throwable> |
assertThrows(ActionRequestBuilder<?,?,?> builder,
java.lang.Class<E> exceptionClass,
RestStatus status)
Run the request from a given builder and check that it throws an exception of the right type, with a given
RestStatus |
static <E extends java.lang.Throwable> |
assertThrows(ActionRequestBuilder<?,?,?> builder,
java.lang.Class<E> exceptionClass,
java.lang.String extraInfo)
Run the request from a given builder and check that it throws an exception of the right type
|
static <E extends java.lang.Throwable> |
assertThrows(ActionRequestBuilder<?,?,?> builder,
RestStatus status) |
static <E extends java.lang.Throwable> |
assertThrows(ActionRequestBuilder<?,?,?> builder,
RestStatus status,
java.lang.String extraInfo) |
static void |
assertToXContentEquivalent(BytesReference expected,
BytesReference actual,
XContentType xContentType)
Asserts that the provided
BytesReference s created through
ToXContent.toXContent(XContentBuilder, ToXContent.Params) hold the same content. |
static void |
assertVersionSerializable(Streamable streamable) |
static void |
assertVersionSerializable(Version version,
java.lang.Exception e) |
static void |
assertVersionSerializable(Version version,
Streamable streamable) |
static void |
assertVersionSerializable(Version version,
Streamable streamable,
NamedWriteableRegistry namedWriteableRegistry) |
static java.lang.String |
formatShardStatus(BroadcastResponse response) |
static java.lang.String |
formatShardStatus(SearchResponse response) |
static org.hamcrest.Matcher<SearchHit> |
hasId(java.lang.String id) |
static org.hamcrest.Matcher<SearchHit> |
hasIndex(java.lang.String index) |
static org.hamcrest.Matcher<SearchHit> |
hasScore(float score) |
static org.hamcrest.Matcher<SearchHit> |
hasType(java.lang.String type) |
public static void assertAcked(AcknowledgedRequestBuilder<?,?,?> builder)
public static void assertNoTimeout(ClusterHealthRequestBuilder requestBuilder)
public static void assertNoTimeout(ClusterHealthResponse response)
public static void assertAcked(AcknowledgedResponse response)
public static void assertAcked(DeleteIndexRequestBuilder builder)
public static void assertAcked(DeleteIndexResponse response)
public static void assertAcked(CreateIndexResponse response)
public static void assertBlocked(ActionRequestBuilder builder)
builder
- the request builderpublic static void assertBlocked(BroadcastResponse replicatedBroadcastResponse)
replicatedBroadcastResponse
- the response that should only contain failed shard responsespublic static void assertBlocked(ActionRequestBuilder builder, ClusterBlock expectedBlock)
ClusterBlock
.builder
- the request builderexpectedBlock
- the expected blockpublic static java.lang.String formatShardStatus(BroadcastResponse response)
public static java.lang.String formatShardStatus(SearchResponse response)
public static void assertNoSearchHits(SearchResponse searchResponse)
public static void assertSearchHits(SearchResponse searchResponse, java.lang.String... ids)
public static void assertSortValues(SearchResponse searchResponse, java.lang.Object[]... sortValues)
public static void assertOrderedSearchHits(SearchResponse searchResponse, java.lang.String... ids)
public static void assertHitCount(SearchResponse countResponse, long expectedHitCount)
public static void assertExists(GetResponse response)
public static void assertFirstHit(SearchResponse searchResponse, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertSecondHit(SearchResponse searchResponse, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertThirdHit(SearchResponse searchResponse, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertFourthHit(SearchResponse searchResponse, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertFifthHit(SearchResponse searchResponse, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertSearchHit(SearchResponse searchResponse, int number, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertNoFailures(SearchResponse searchResponse)
public static void assertFailures(SearchResponse searchResponse)
public static void assertNoFailures(BulkResponse response)
public static void assertFailures(SearchRequestBuilder searchRequestBuilder, RestStatus restStatus, org.hamcrest.Matcher<java.lang.String> reasonMatcher)
public static void assertNoFailures(BroadcastResponse response)
public static void assertAllSuccessful(BroadcastResponse response)
public static void assertAllSuccessful(SearchResponse response)
public static void assertSearchHit(SearchHit searchHit, org.hamcrest.Matcher<SearchHit> matcher)
public static void assertHighlight(SearchResponse resp, int hit, java.lang.String field, int fragment, org.hamcrest.Matcher<java.lang.String> matcher)
public static void assertHighlight(SearchResponse resp, int hit, java.lang.String field, int fragment, int totalFragments, org.hamcrest.Matcher<java.lang.String> matcher)
public static void assertHighlight(SearchHit hit, java.lang.String field, int fragment, org.hamcrest.Matcher<java.lang.String> matcher)
public static void assertHighlight(SearchHit hit, java.lang.String field, int fragment, int totalFragments, org.hamcrest.Matcher<java.lang.String> matcher)
public static void assertNotHighlighted(SearchResponse resp, int hit, java.lang.String field)
public static void assertSuggestionSize(Suggest searchSuggest, int entry, int size, java.lang.String key)
public static void assertSuggestionPhraseCollateMatchExists(Suggest searchSuggest, java.lang.String key, int numberOfPhraseExists)
public static void assertSuggestion(Suggest searchSuggest, int entry, int ord, java.lang.String key, java.lang.String text)
public static void assertSuggestion(Suggest searchSuggest, int entry, java.lang.String key, java.lang.String... text)
public static void assertSuggestion(Suggest searchSuggest, int entry, java.lang.String key, int size, java.lang.String... text)
public static void assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse, java.lang.String name)
public static void assertIndexTemplateExists(GetIndexTemplatesResponse templatesResponse, java.lang.String name)
public static void assertAliasesMissing(AliasesExistResponse aliasesExistResponse)
public static void assertAliasesExist(AliasesExistResponse aliasesExistResponse)
public static org.hamcrest.Matcher<SearchHit> hasId(java.lang.String id)
public static org.hamcrest.Matcher<SearchHit> hasType(java.lang.String type)
public static org.hamcrest.Matcher<SearchHit> hasIndex(java.lang.String index)
public static org.hamcrest.Matcher<SearchHit> hasScore(float score)
public static <T extends Query> T assertBooleanSubQuery(Query query, java.lang.Class<T> subqueryType, int i)
public static <T extends Query> T assertDisjunctionSubQuery(Query query, java.lang.Class<T> subqueryType, int i)
public static <E extends java.lang.Throwable> void assertThrows(ActionRequestBuilder<?,?,?> builder, java.lang.Class<E> exceptionClass)
public static <E extends java.lang.Throwable> void assertThrows(ActionRequestBuilder<?,?,?> builder, java.lang.Class<E> exceptionClass, RestStatus status)
RestStatus
public static <E extends java.lang.Throwable> void assertThrows(ActionRequestBuilder<?,?,?> builder, java.lang.Class<E> exceptionClass, java.lang.String extraInfo)
extraInfo
- extra information to add to the failure messagepublic static <E extends java.lang.Throwable> void assertThrows(ActionFuture future, java.lang.Class<E> exceptionClass)
public static <E extends java.lang.Throwable> void assertThrows(ActionFuture future, java.lang.Class<E> exceptionClass, RestStatus status)
RestStatus
public static <E extends java.lang.Throwable> void assertThrows(ActionFuture future, java.lang.Class<E> exceptionClass, java.lang.String extraInfo)
extraInfo
- extra information to add to the failure messagepublic static <E extends java.lang.Throwable> void assertThrows(ActionFuture future, java.lang.Class<E> exceptionClass, @Nullable RestStatus status, @Nullable java.lang.String extraInfo)
exceptionClass
- expected exception classstatus
- RestStatus
to check for. Can be null to disable the checkextraInfo
- extra information to add to the failure message. Can be null.public static <E extends java.lang.Throwable> void assertThrows(ActionRequestBuilder<?,?,?> builder, RestStatus status)
public static <E extends java.lang.Throwable> void assertThrows(ActionRequestBuilder<?,?,?> builder, RestStatus status, java.lang.String extraInfo)
public static <E extends java.lang.Throwable> void assertThrows(ActionFuture future, RestStatus status)
public static void assertThrows(ActionFuture future, RestStatus status, java.lang.String extraInfo)
public static void assertVersionSerializable(Streamable streamable)
public static void assertVersionSerializable(Version version, Streamable streamable)
public static void assertVersionSerializable(Version version, Streamable streamable, NamedWriteableRegistry namedWriteableRegistry)
public static void assertVersionSerializable(Version version, java.lang.Exception e)
public static SearchResponse assertSearchResponse(SearchRequestBuilder request)
public static SearchResponse assertSearchResponse(SearchResponse response)
public static void assertFileExists(java.nio.file.Path file)
public static void assertFileNotExists(java.nio.file.Path file)
public static void assertDirectoryExists(java.nio.file.Path dir)
public static void assertToXContentEquivalent(BytesReference expected, BytesReference actual, XContentType xContentType) throws java.io.IOException
BytesReference
s created through
ToXContent.toXContent(XContentBuilder, ToXContent.Params)
hold the same content.
The comparison is done by parsing both into a map and comparing those two, so that keys ordering doesn't matter.
Also binary values (byte[]) are properly compared through arrays comparisons.java.io.IOException