|
54 | 54 | import org.mockito.InOrder; |
55 | 55 |
|
56 | 56 | import java.util.ArrayList; |
| 57 | +import java.util.Collections; |
57 | 58 | import java.util.HashMap; |
58 | 59 | import java.util.HashSet; |
59 | 60 | import java.util.List; |
|
69 | 70 | import static org.mockito.Mockito.inOrder; |
70 | 71 | import static org.mockito.Mockito.mock; |
71 | 72 | import static org.mockito.Mockito.verify; |
| 73 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
72 | 74 | import static org.mockito.Mockito.when; |
73 | 75 |
|
74 | 76 | public class JestElasticsearchClientTest { |
@@ -145,6 +147,23 @@ public void getsVersion() { |
145 | 147 | assertThat(client.getVersion(), is(equalTo(ElasticsearchClient.Version.ES_V1))); |
146 | 148 | } |
147 | 149 |
|
| 150 | + @Test |
| 151 | + public void attemptToCreateExistingIndex() throws Exception { |
| 152 | + JestElasticsearchClient client = new JestElasticsearchClient(jestClient); |
| 153 | + JestResult success = new JestResult(new Gson()); |
| 154 | + success.setSucceeded(true); |
| 155 | + IndicesExists indicesExists = new IndicesExists.Builder(INDEX).build(); |
| 156 | + when(jestClient.execute(indicesExists)).thenReturn(success); |
| 157 | + when(jestClient.execute(argThat(isCreateIndexForTestIndex()))).thenReturn(success); |
| 158 | + |
| 159 | + client.createIndices(Collections.singleton(INDEX)); |
| 160 | + InOrder inOrder = inOrder(jestClient); |
| 161 | + inOrder.verify(jestClient).execute(info); |
| 162 | + inOrder.verify(jestClient).execute(indicesExists); |
| 163 | + |
| 164 | + verifyNoMoreInteractions(jestClient); |
| 165 | + } |
| 166 | + |
148 | 167 | @Test |
149 | 168 | public void createsIndices() throws Exception { |
150 | 169 | JestElasticsearchClient client = new JestElasticsearchClient(jestClient); |
|
0 commit comments