|
36 | 36 | import io.searchbox.indices.IndicesExists; |
37 | 37 | import io.searchbox.indices.mapping.GetMapping; |
38 | 38 | import io.searchbox.indices.mapping.PutMapping; |
| 39 | +import java.util.Collections; |
39 | 40 | import org.apache.kafka.connect.data.Schema; |
40 | 41 | import org.apache.kafka.connect.errors.ConnectException; |
41 | 42 | import org.junit.Before; |
|
56 | 57 | import static org.mockito.Mockito.inOrder; |
57 | 58 | import static org.mockito.Mockito.mock; |
58 | 59 | import static org.mockito.Mockito.verify; |
| 60 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
59 | 61 | import static org.mockito.Mockito.when; |
60 | 62 |
|
61 | 63 | public class JestElasticsearchClientTest { |
@@ -89,6 +91,23 @@ public void getsVersion() { |
89 | 91 | assertThat(client.getVersion(), is(equalTo(ElasticsearchClient.Version.ES_V1))); |
90 | 92 | } |
91 | 93 |
|
| 94 | + @Test |
| 95 | + public void attemptToCreateExistingIndex() throws Exception { |
| 96 | + JestElasticsearchClient client = new JestElasticsearchClient(jestClient); |
| 97 | + JestResult success = new JestResult(new Gson()); |
| 98 | + success.setSucceeded(true); |
| 99 | + IndicesExists indicesExists = new IndicesExists.Builder(INDEX).build(); |
| 100 | + when(jestClient.execute(indicesExists)).thenReturn(success); |
| 101 | + when(jestClient.execute(argThat(isCreateIndexForTestIndex()))).thenReturn(success); |
| 102 | + |
| 103 | + client.createIndices(Collections.singleton(INDEX)); |
| 104 | + InOrder inOrder = inOrder(jestClient); |
| 105 | + inOrder.verify(jestClient).execute(info); |
| 106 | + inOrder.verify(jestClient).execute(indicesExists); |
| 107 | + |
| 108 | + verifyNoMoreInteractions(jestClient); |
| 109 | + } |
| 110 | + |
92 | 111 | @Test |
93 | 112 | public void createsIndices() throws Exception { |
94 | 113 | JestElasticsearchClient client = new JestElasticsearchClient(jestClient); |
|
0 commit comments