From c884adf603b22b1db22320b092627fc5983e484d Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 24 Jun 2011 15:52:45 +0300 Subject: [PATCH] more get tests --- .../integration/document/GetActionTests.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java index a3da4e8154d..1b3a70e5e3c 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.test.integration.document; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; +import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.ImmutableSettings; @@ -110,5 +111,28 @@ public class GetActionTests extends AbstractNodesTests { assertThat(response.source(), nullValue()); assertThat(response.field("field1").values().get(0).toString(), equalTo("value1")); assertThat(response.field("field2"), nullValue()); + + logger.info("--> update doc 1"); + client.prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").execute().actionGet(); + + logger.info("--> realtime get 1"); + response = client.prepareGet("test", "type1", "1").execute().actionGet(); + assertThat(response.exists(), equalTo(true)); + assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1_1")); + assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2_1")); + + logger.info("--> update doc 1 again"); + client.prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").execute().actionGet(); + + response = client.prepareGet("test", "type1", "1").execute().actionGet(); + assertThat(response.exists(), equalTo(true)); + assertThat(response.sourceAsMap().get("field1").toString(), equalTo("value1_2")); + assertThat(response.sourceAsMap().get("field2").toString(), equalTo("value2_2")); + + DeleteResponse deleteResponse = client.prepareDelete("test", "type1", "1").execute().actionGet(); + assertThat(deleteResponse.notFound(), equalTo(false)); + + response = client.prepareGet("test", "type1", "1").execute().actionGet(); + assertThat(response.exists(), equalTo(false)); } } \ No newline at end of file