Stop using isCreated and isFound
These are going away in core and being replaced by `getOperation`. Original commit: elastic/x-pack-elasticsearch@7413b12911
This commit is contained in:
commit
c0df62e0e9
|
@ -13,6 +13,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.LatchedActionListener;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
|
@ -325,7 +326,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
.execute(new ActionListener<UpdateResponse>() {
|
||||
@Override
|
||||
public void onResponse(UpdateResponse updateResponse) {
|
||||
assert updateResponse.isCreated() == false;
|
||||
assert updateResponse.getOperation() == DocWriteResponse.Operation.INDEX;
|
||||
clearRealmCache(request.username(), listener, null);
|
||||
}
|
||||
|
||||
|
@ -401,7 +402,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
.execute(new ActionListener<UpdateResponse>() {
|
||||
@Override
|
||||
public void onResponse(UpdateResponse updateResponse) {
|
||||
assert updateResponse.isCreated() == false;
|
||||
assert updateResponse.getOperation() == DocWriteResponse.Operation.INDEX;
|
||||
clearRealmCache(putUserRequest.username(), listener, false);
|
||||
}
|
||||
|
||||
|
@ -442,12 +443,13 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
@Override
|
||||
public void onResponse(IndexResponse indexResponse) {
|
||||
// if the document was just created, then we don't need to clear cache
|
||||
if (indexResponse.isCreated()) {
|
||||
listener.onResponse(indexResponse.isCreated());
|
||||
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
|
||||
if (created) {
|
||||
listener.onResponse(true);
|
||||
return;
|
||||
}
|
||||
|
||||
clearRealmCache(putUserRequest.username(), listener, indexResponse.isCreated());
|
||||
clearRealmCache(putUserRequest.username(), listener, created);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -471,7 +473,8 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
client.delete(request, new ActionListener<DeleteResponse>() {
|
||||
@Override
|
||||
public void onResponse(DeleteResponse deleteResponse) {
|
||||
clearRealmCache(deleteUserRequest.username(), listener, deleteResponse.isFound());
|
||||
clearRealmCache(deleteUserRequest.username(), listener,
|
||||
deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.function.Function;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.LatchedActionListener;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
|
@ -273,7 +274,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
client.delete(request, new ActionListener<DeleteResponse>() {
|
||||
@Override
|
||||
public void onResponse(DeleteResponse deleteResponse) {
|
||||
clearRoleCache(deleteRoleRequest.name(), listener, deleteResponse.isFound());
|
||||
clearRoleCache(deleteRoleRequest.name(), listener, deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -303,11 +304,12 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
.execute(new ActionListener<IndexResponse>() {
|
||||
@Override
|
||||
public void onResponse(IndexResponse indexResponse) {
|
||||
if (indexResponse.isCreated()) {
|
||||
listener.onResponse(indexResponse.isCreated());
|
||||
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
|
||||
if (created) {
|
||||
listener.onResponse(true);
|
||||
return;
|
||||
}
|
||||
clearRoleCache(role.getName(), listener, indexResponse.isCreated());
|
||||
clearRoleCache(role.getName(), listener, created);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,9 +10,9 @@ import org.apache.http.entity.ContentType;
|
|||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -28,7 +28,6 @@ import java.util.Collections;
|
|||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class BulkUpdateTests extends SecurityIntegTestCase {
|
||||
|
||||
|
@ -42,7 +41,8 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
public void testThatBulkUpdateDoesNotLoseFields() {
|
||||
assertThat(client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}").setId("1").get().isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE,
|
||||
client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}").setId("1").get().getOperation());
|
||||
GetResponse getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test").get();
|
||||
assertThat(getResponse.getField("test").getValue(), equalTo("test"));
|
||||
|
||||
|
@ -51,9 +51,8 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
// update with a new field
|
||||
boolean created = internalCluster().transportClient().prepareUpdate("index1", "type", "1").setDoc("{\"not test\": \"not test\"}")
|
||||
.get().isCreated();
|
||||
assertThat(created, is(false));
|
||||
assertEquals(DocWriteResponse.Operation.INDEX, internalCluster().transportClient().prepareUpdate("index1", "type", "1")
|
||||
.setDoc("{\"not test\": \"not test\"}").get().getOperation());
|
||||
getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test", "not test").get();
|
||||
assertThat(getResponse.getField("test").getValue(), equalTo("test"));
|
||||
assertThat(getResponse.getField("not test").getValue(), equalTo("not test"));
|
||||
|
@ -65,7 +64,7 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
|
|||
// do it in a bulk
|
||||
BulkResponse response = internalCluster().transportClient().prepareBulk().add(client().prepareUpdate("index1", "type", "1")
|
||||
.setDoc("{\"bulk updated\": \"bulk updated\"}")).get();
|
||||
assertThat(((UpdateResponse)response.getItems()[0].getResponse()).isCreated(), is(false));
|
||||
assertEquals(DocWriteResponse.Operation.INDEX, response.getItems()[0].getResponse().getOperation());
|
||||
getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").
|
||||
setFields("test", "not test", "bulk updated").get();
|
||||
assertThat(getResponse.getField("test").getValue(), equalTo("test"));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.integration;
|
||||
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
|
@ -119,7 +120,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
|
|||
.setDoc("run_as", new String[] { role })
|
||||
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
|
||||
.get();
|
||||
assertThat(response.isCreated(), is(false));
|
||||
assertEquals(DocWriteResponse.Operation.INDEX, response.getOperation());
|
||||
logger.debug("--> updated role [{}] with run_as", role);
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
|
|||
.prepareDelete(SecurityTemplateService.SECURITY_INDEX_NAME, NativeRolesStore.ROLE_DOC_TYPE, role)
|
||||
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
|
||||
.get();
|
||||
assertThat(response.isFound(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
|
||||
|
||||
assertBusy(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.integration;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
|
@ -69,7 +70,7 @@ public class DateMathExpressionIntegTests extends SecurityIntegTestCase {
|
|||
IndexResponse response = client.prepareIndex(expression, "type").setSource("foo", "bar")
|
||||
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE).get();
|
||||
|
||||
assertThat(response.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
|
||||
assertThat(response.getIndex(), containsString(expectedIndexName));
|
||||
|
||||
if (refeshOnOperation == false) {
|
||||
|
@ -89,7 +90,7 @@ public class DateMathExpressionIntegTests extends SecurityIntegTestCase {
|
|||
.setDoc("new", "field")
|
||||
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE)
|
||||
.get();
|
||||
assertThat(updateResponse.isCreated(), is(false));
|
||||
assertEquals(DocWriteResponse.Operation.INDEX, updateResponse.getOperation());
|
||||
|
||||
if (refeshOnOperation == false) {
|
||||
client.admin().indices().prepareRefresh(expression).get();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.integration;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
|
||||
|
@ -186,13 +187,13 @@ public class KibanaUserRoleIntegTests extends SecurityIntegTestCase {
|
|||
.setSource("foo", "bar")
|
||||
.setRefreshPolicy(IMMEDIATE)
|
||||
.get();
|
||||
assertThat(response.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
|
||||
|
||||
DeleteResponse deleteResponse = client()
|
||||
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.prepareDelete(index, "dashboard", response.getId())
|
||||
.get();
|
||||
assertThat(deleteResponse.isFound(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.DELETE, deleteResponse.getOperation());
|
||||
}
|
||||
|
||||
// TODO: When we have an XPackIntegTestCase, this should test that we can send MonitoringBulkActions
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.integration;
|
||||
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.MultiSearchResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -75,14 +76,14 @@ public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase {
|
|||
.startObject()
|
||||
.field("name", "value")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
|
||||
indexResponse = index("test1", "type", jsonBuilder()
|
||||
.startObject()
|
||||
.field("name", "value1")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
refresh();
|
||||
|
||||
|
@ -150,13 +151,13 @@ public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase {
|
|||
.startObject()
|
||||
.field("name", "value_a")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
indexResponse = index("b", "type", jsonBuilder()
|
||||
.startObject()
|
||||
.field("name", "value_b")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
refresh();
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.integration.ldap;
|
||||
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
|
@ -132,7 +133,8 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase
|
|||
.endObject())
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat("user " + user + " should have write access to index " + index, indexResponse.isCreated(), is(true));
|
||||
assertEquals("user " + user + " should have write access to index " + index,
|
||||
DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
refresh();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
||||
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsIndices;
|
||||
|
@ -114,14 +115,14 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
.startObject()
|
||||
.field("name", "value")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
|
||||
indexResponse = index("test1", "type", jsonBuilder()
|
||||
.startObject()
|
||||
.field("name", "value1")
|
||||
.endObject());
|
||||
assertThat(indexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
|
||||
|
||||
refresh();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.apache.http.client.methods.HttpPut;
|
|||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
|
@ -79,7 +80,7 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase {
|
|||
try (TransportClient client = createTransportClient(settings)) {
|
||||
client.addTransportAddress(randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses()));
|
||||
IndexResponse response = client.prepareIndex("foo", "bar").setSource("pki", "auth").get();
|
||||
assertThat(response.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher;
|
|||
|
||||
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -15,7 +16,6 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.engine.VersionConflictEngineException;
|
||||
import org.elasticsearch.xpack.common.stats.Counters;
|
||||
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
|
@ -29,7 +29,6 @@ import org.joda.time.DateTimeZone;
|
|||
import org.joda.time.PeriodType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
@ -122,7 +121,7 @@ public class WatcherService extends AbstractComponent {
|
|||
}
|
||||
try {
|
||||
WatchStore.WatchDelete delete = watchStore.delete(id, force);
|
||||
if (delete.deleteResponse().isFound()) {
|
||||
if (delete.deleteResponse().getOperation() == DocWriteResponse.Operation.DELETE) {
|
||||
triggerService.remove(id);
|
||||
}
|
||||
return delete;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.actions.index;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
|
@ -116,7 +117,8 @@ public class ExecutableIndexAction extends ExecutableAction<IndexAction> {
|
|||
|
||||
static void indexResponseToXContent(XContentBuilder builder, IndexResponse response) throws IOException {
|
||||
builder.startObject()
|
||||
.field("created", response.isCreated())
|
||||
.field("created", response.getOperation() == DocWriteResponse.Operation.CREATE)
|
||||
.field("operation", response.getOperation().getLowercase())
|
||||
.field("id", response.getId())
|
||||
.field("version", response.getVersion())
|
||||
.field("type", response.getType())
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.transport.actions.delete;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
|
@ -56,8 +57,8 @@ public class TransportDeleteWatchAction extends WatcherTransportAction<DeleteWat
|
|||
try {
|
||||
DeleteResponse deleteResponse = watcherService.deleteWatch(request.getId(), request.masterNodeTimeout(), request.isForce())
|
||||
.deleteResponse();
|
||||
DeleteWatchResponse response = new DeleteWatchResponse(deleteResponse.getId(), deleteResponse.getVersion(), deleteResponse
|
||||
.isFound());
|
||||
boolean deleted = deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE;
|
||||
DeleteWatchResponse response = new DeleteWatchResponse(deleteResponse.getId(), deleteResponse.getVersion(), deleted);
|
||||
listener.onResponse(response);
|
||||
} catch (Exception e) {
|
||||
listener.onFailure(e);
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.transport.actions.put;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
|
@ -62,7 +63,8 @@ public class TransportPutWatchAction extends WatcherTransportAction<PutWatchRequ
|
|||
try {
|
||||
IndexResponse indexResponse = watcherService.putWatch(request.getId(), request.getSource(), request.masterNodeTimeout(),
|
||||
request.isActive());
|
||||
listener.onResponse(new PutWatchResponse(indexResponse.getId(), indexResponse.getVersion(), indexResponse.isCreated()));
|
||||
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
|
||||
listener.onResponse(new PutWatchResponse(indexResponse.getId(), indexResponse.getVersion(), created));
|
||||
} catch (Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.xpack.watcher;
|
||||
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -169,7 +170,7 @@ public class WatcherServiceTests extends ESTestCase {
|
|||
|
||||
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
|
||||
DeleteResponse deleteResponse = mock(DeleteResponse.class);
|
||||
when(deleteResponse.isFound()).thenReturn(true);
|
||||
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.DELETE);
|
||||
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
|
||||
when(watchStore.delete("_id", force)).thenReturn(expectedWatchDelete);
|
||||
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, force);
|
||||
|
@ -198,7 +199,7 @@ public class WatcherServiceTests extends ESTestCase {
|
|||
|
||||
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
|
||||
DeleteResponse deleteResponse = mock(DeleteResponse.class);
|
||||
when(deleteResponse.isFound()).thenReturn(true);
|
||||
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.DELETE);
|
||||
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
|
||||
when(watchStore.delete("_id", true)).thenReturn(expectedWatchDelete);
|
||||
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, true);
|
||||
|
@ -215,7 +216,7 @@ public class WatcherServiceTests extends ESTestCase {
|
|||
|
||||
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
|
||||
DeleteResponse deleteResponse = mock(DeleteResponse.class);
|
||||
when(deleteResponse.isFound()).thenReturn(false);
|
||||
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.NOOP);
|
||||
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
|
||||
when(watchStore.delete("_id", force)).thenReturn(expectedWatchDelete);
|
||||
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, force);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.actions;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
||||
|
@ -43,7 +44,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
IndexResponse eventIndexResponse = client().prepareIndex("events", "event")
|
||||
.setSource("level", "error")
|
||||
.get();
|
||||
assertThat(eventIndexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, eventIndexResponse.getOperation());
|
||||
refresh();
|
||||
return eventIndexResponse;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.watcher.test.integration;
|
|||
|
||||
import org.apache.lucene.util.LuceneTestCase.BadApple;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
|
@ -58,7 +59,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
IndexResponse eventIndexResponse = client().prepareIndex("events", "event")
|
||||
.setSource("level", "error")
|
||||
.get();
|
||||
assertThat(eventIndexResponse.isCreated(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.CREATE, eventIndexResponse.getOperation());
|
||||
refresh();
|
||||
return eventIndexResponse;
|
||||
}
|
||||
|
@ -114,7 +115,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
|
||||
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
||||
DeleteResponse response = client().prepareDelete("events", "event", eventIndexResponse.getId()).get();
|
||||
assertThat(response.isFound(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
|
||||
refresh();
|
||||
|
||||
if (timeWarped()) {
|
||||
|
@ -196,7 +197,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
|
||||
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
||||
DeleteResponse response = client().prepareDelete("events", "event", eventIndexResponse.getId()).get();
|
||||
assertThat(response.isFound(), is(true));
|
||||
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
|
||||
refresh();
|
||||
|
||||
if (timeWarped()) {
|
||||
|
|
Loading…
Reference in New Issue