aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@sonarsource.com>2014-10-08 09:28:20 +0200
committerStephane Gamard <stephane.gamard@sonarsource.com>2014-10-08 09:32:54 +0200
commitcf54b1c0e0d60106286136d59d193c12380d0145 (patch)
tree7a06872ce8095931154ea8fdf207fa31a4d54eaa /server/sonar-server
parent9954d931c301d4b1e25d6aaf04a714f99670c0b2 (diff)
downloadsonarqube-cf54b1c0e0d60106286136d59d193c12380d0145.tar.gz
sonarqube-cf54b1c0e0d60106286136d59d193c12380d0145.zip
add test for DeleteKey es cluster action
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java
new file mode 100644
index 00000000000..acb7e10ebe3
--- /dev/null
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java
@@ -0,0 +1,42 @@
+package org.sonar.server.search.action;
+
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.sonar.server.search.Index;
+import org.sonar.server.search.IndexDefinition;
+
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+public class DeleteKeyTest {
+
+ IndexDefinition TEST_INDEX = IndexDefinition.createFor("TEST", "TESTING");
+
+ @Mock
+ Index index;
+
+ @Before
+ public void setUp() throws Exception {
+ when(index.getIndexName()).thenReturn(TEST_INDEX.getIndexName());
+
+ }
+
+ @Test
+ public void get_delete_request() throws Exception {
+ String key = "test_key";
+ DeleteKey<String> deleteAction = new DeleteKey<String>(TEST_INDEX.getIndexType(), key);
+
+ List<DeleteRequest> requests = deleteAction.doCall(index);
+ assertThat(requests).hasSize(1);
+
+ DeleteRequest request = requests.get(0);
+ assertThat(request.type()).isEqualTo(TEST_INDEX.getIndexType());
+ assertThat(request.index()).isEqualTo(TEST_INDEX.getIndexName());
+ assertThat(request.id()).isEqualTo(key);
+ assertThat(request.refresh()).isTrue();
+ }
+}