@Test public void fail_on_bad_query() { try { es.client().preparePutMapping().get(); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class); assertThat(e.getMessage()).contains("Fail to execute ES put mapping request"); } }
@Test public void to_string() { assertThat(es.client().preparePutMapping(FakeIndexDefinition.INDEX).setSource(mapDomain()).toString()) .isEqualTo("ES put mapping request on indices 'fakes' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'"); assertThat(es.client().preparePutMapping(FakeIndexDefinition.INDEX).setType(FakeIndexDefinition.TYPE).setSource(mapDomain()).toString()) .isEqualTo("ES put mapping request on indices 'fakes' on type 'fake' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'"); }
@Test public void execute_should_throw_an_unsupported_operation_exception() { try { es.client().preparePutMapping().execute(); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous"); } }
@Test public void get_with_string_timeout_is_not_yet_implemented() { try { es.client().preparePutMapping().get("1"); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().preparePutMapping().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
PutMappingResponse mappingResponse = client.preparePutMapping(index.getName()) .setType(entry.getKey()) .setSource(entry.getValue().getAttributes())
@Test public void trace_logs() { logTester.setLevel(LoggerLevel.TRACE); PutMappingRequestBuilder requestBuilder = es.client().preparePutMapping(FakeIndexDefinition.INDEX) .setType(FakeIndexDefinition.TYPE) .setSource(mapDomain()); requestBuilder.get(); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); }
@Test public void proxify_requests() { EsClient underTest = es.client(); assertThat(underTest.nativeClient()).isNotNull(); assertThat(underTest.prepareClusterStats()).isInstanceOf(ProxyClusterStatsRequestBuilder.class); assertThat(underTest.prepareCreate("fakes")).isInstanceOf(ProxyCreateIndexRequestBuilder.class); assertThat(underTest.prepareDelete("fakes", "fake", "my_id")).isInstanceOf(ProxyDeleteRequestBuilder.class); assertThat(underTest.prepareIndicesExist()).isInstanceOf(ProxyIndicesExistsRequestBuilder.class); assertThat(underTest.prepareGet(new IndexType("fakes", "fake"), "1")).isInstanceOf(ProxyGetRequestBuilder.class); assertThat(underTest.prepareHealth()).isInstanceOf(ProxyClusterHealthRequestBuilder.class); assertThat(underTest.prepareNodesStats()).isInstanceOf(ProxyNodesStatsRequestBuilder.class); assertThat(underTest.preparePutMapping()).isInstanceOf(ProxyPutMappingRequestBuilder.class); assertThat(underTest.prepareRefresh()).isInstanceOf(ProxyRefreshRequestBuilder.class); assertThat(underTest.prepareSearch(new IndexType[0])).isInstanceOf(ProxySearchRequestBuilder.class); assertThat(underTest.prepareSearchScroll("1234")).isInstanceOf(ProxySearchScrollRequestBuilder.class); assertThat(underTest.prepareState()).isInstanceOf(ProxyClusterStateRequestBuilder.class); assertThat(underTest.prepareStats()).isInstanceOf(ProxyIndicesStatsRequestBuilder.class); underTest.close(); } }
@Test public void put_mapping() { PutMappingRequestBuilder requestBuilder = es.client().preparePutMapping(FakeIndexDefinition.INDEX) .setType(FakeIndexDefinition.TYPE) .setSource(mapDomain()); requestBuilder.get(); }
PutMappingResponse mappingResponse = client.preparePutMapping(index.getName()) .setType(entry.getKey()) .setSource(entry.getValue().getAttributes())