From 5f4c6c75aedd71caf793866faf54f628f00dd1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Sun, 12 Jun 2011 12:04:18 +0200 Subject: [PATCH] cleaned Groovy classes * added type information to public methods * removed semicolons * replaced GStrings with Strings --- .../groovy/client/GAdminClient.groovy | 10 +- .../groovy/client/GClient.groovy | 40 ++++---- .../groovy/client/GClusterAdminClient.groovy | 22 ++--- .../groovy/client/GIndicesAdminClient.groovy | 46 ++++----- .../common/xcontent/GXContentBuilder.groovy | 25 +++-- .../elasticsearch/groovy/node/GNode.groovy | 21 ++-- .../groovy/node/GNodeBuilder.groovy | 24 ++--- .../xcontent/GXContentBuilderTests.groovy | 15 ++- .../test/client/BuilderActionsTests.groovy | 42 ++++---- .../client/DifferentApiExecutionTests.groovy | 98 +++++++++---------- .../test/client/SimpleActionsTests.groovy | 83 ++++++++-------- .../groovy/test/node/GNodeBuilderTests.groovy | 4 +- 12 files changed, 212 insertions(+), 218 deletions(-) diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy index 6bd02abd734..22f5bd964b1 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy @@ -24,14 +24,14 @@ package org.elasticsearch.groovy.client */ class GAdminClient { - private final GClient gClient; + private final GClient gClient - final GIndicesAdminClient indices; + final GIndicesAdminClient indices - final GClusterAdminClient cluster; + final GClusterAdminClient cluster - def GAdminClient(gClient) { - this.gClient = gClient; + GAdminClient(gClient) { + this.gClient = gClient this.indices = new GIndicesAdminClient(gClient) this.cluster = new GClusterAdminClient(gClient) diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy index 07fac1430d2..b531dfe2028 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy @@ -54,8 +54,8 @@ class GClient { static { BaseRequestBuilder.metaClass.gexecute = { - ListenableActionFuture future = delegate.execute(); - return new GActionFuture(future); + ListenableActionFuture future = delegate.execute() + return new GActionFuture(future) } IndexRequest.metaClass.setSource = {Closure c -> @@ -148,31 +148,31 @@ class GClient { } } - public static XContentType contentType = XContentType.SMILE; + public static XContentType contentType = XContentType.SMILE - public static XContentType indexContentType = XContentType.JSON; + public static XContentType indexContentType = XContentType.JSON - final Client client; + final Client client int resolveStrategy = Closure.DELEGATE_FIRST private final InternalClient internalClient - final GAdminClient admin; + final GAdminClient admin - def GClient(client) { - this.client = client; - this.internalClient = client; + GClient(client) { + this.client = client + this.internalClient = client this.admin = new GAdminClient(this) } IndexRequestBuilder prepareIndex(String index, String type) { - return client.prepareIndex(index, type); + return client.prepareIndex(index, type) } IndexRequestBuilder prepareIndex(String index, String type, String id) { - return client.prepareIndex(index, type, id); + return client.prepareIndex(index, type, id) } GActionFuture index(Closure c) { @@ -184,7 +184,7 @@ class GClient { } GActionFuture index(IndexRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.index(request, future) return future } @@ -194,7 +194,7 @@ class GClient { } GetRequestBuilder prepareGet(String index, String type, String id) { - return client.prepareGet(index, type, id); + return client.prepareGet(index, type, id) } GActionFuture get(Closure c) { @@ -206,7 +206,7 @@ class GClient { } GActionFuture get(GetRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.get(request, future) return future } @@ -228,7 +228,7 @@ class GClient { } GActionFuture delete(DeleteRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.delete(request, future) return future } @@ -238,7 +238,7 @@ class GClient { } DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) { - return client.prepareDeleteByQuery(indices); + return client.prepareDeleteByQuery(indices) } GActionFuture deleteByQuery(Closure c) { @@ -250,7 +250,7 @@ class GClient { } GActionFuture deleteByQuery(DeleteByQueryRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.deleteByQuery(request, future) return future } @@ -272,7 +272,7 @@ class GClient { } GActionFuture count(CountRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.count(request, future) return future } @@ -294,7 +294,7 @@ class GClient { } GActionFuture search(SearchRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.search(request, future) return future } @@ -312,7 +312,7 @@ class GClient { } GActionFuture moreLikeThis(MoreLikeThisRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) client.moreLikeThis(request, future) return future } diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy index 64bbb491fdd..c8a7134df1f 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy @@ -49,14 +49,14 @@ class GClusterAdminClient { private final GClient gClient - private final InternalClient internalClient; + private final InternalClient internalClient - final ClusterAdminClient clusterAdminClient; + final ClusterAdminClient clusterAdminClient def GClusterAdminClient(gClient) { - this.gClient = gClient; - this.internalClient = gClient.client; - this.clusterAdminClient = internalClient.admin().cluster(); + this.gClient = gClient + this.internalClient = gClient.client + this.clusterAdminClient = internalClient.admin().cluster() } // HEALTH @@ -74,7 +74,7 @@ class GClusterAdminClient { } GActionFuture health(ClusterHealthRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.health(request, future) return future } @@ -98,7 +98,7 @@ class GClusterAdminClient { } GActionFuture state(ClusterStateRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.state(request, future) return future } @@ -122,7 +122,7 @@ class GClusterAdminClient { } GActionFuture nodesInfo(NodesInfoRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.nodesInfo(request, future) return future } @@ -146,7 +146,7 @@ class GClusterAdminClient { } GActionFuture nodesStats(NodesStatsRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.nodesStats(request, future) return future } @@ -170,7 +170,7 @@ class GClusterAdminClient { } GActionFuture nodesShutdown(NodesShutdownRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.nodesShutdown(request, future) return future } @@ -194,7 +194,7 @@ class GClusterAdminClient { } GActionFuture nodesRestart(NodesRestartRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) clusterAdminClient.nodesRestart(request, future) return future } diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy index 3775db80997..1ef8fdd0afa 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy @@ -124,14 +124,14 @@ class GIndicesAdminClient { private final GClient gClient - private final InternalClient internalClient; + private final InternalClient internalClient - final IndicesAdminClient indicesAdminClient; + final IndicesAdminClient indicesAdminClient def GIndicesAdminClient(gClient) { this.gClient = gClient this.internalClient = gClient.client - this.indicesAdminClient = internalClient.admin().indices(); + this.indicesAdminClient = internalClient.admin().indices() } // STATUS @@ -149,7 +149,7 @@ class GIndicesAdminClient { } GActionFuture status(IndicesStatusRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.status(request, future) return future } @@ -173,7 +173,7 @@ class GIndicesAdminClient { } GActionFuture create(CreateIndexRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.create(request, future) return future } @@ -197,7 +197,7 @@ class GIndicesAdminClient { } GActionFuture delete(DeleteIndexRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.delete(request, future) return future } @@ -221,7 +221,7 @@ class GIndicesAdminClient { } GActionFuture refresh(RefreshRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.refresh(request, future) return future } @@ -245,7 +245,7 @@ class GIndicesAdminClient { } GActionFuture flush(FlushRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.flush(request, future) return future } @@ -269,7 +269,7 @@ class GIndicesAdminClient { } GActionFuture optimize(OptimizeRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.optimize(request, future) return future } @@ -293,7 +293,7 @@ class GIndicesAdminClient { } GActionFuture putMapping(PutMappingRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.putMapping(request, future) return future } @@ -317,7 +317,7 @@ class GIndicesAdminClient { } GActionFuture gatewaySnapshot(GatewaySnapshotRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.gatewaySnapshot(request, future) return future } @@ -341,7 +341,7 @@ class GIndicesAdminClient { } GActionFuture aliases(IndicesAliasesRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.aliases(request, future) return future } @@ -369,7 +369,7 @@ class GIndicesAdminClient { } GActionFuture clearCache(ClearIndicesCacheRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.clearCache(request, future) return future } @@ -389,7 +389,7 @@ class GIndicesAdminClient { } GActionFuture updateSettings(UpdateSettingsRequest request) { - GActionFuture future = new GActionFuture(internalClient.threadPool(), request); + GActionFuture future = new GActionFuture(internalClient.threadPool(), request) indicesAdminClient.updateSettings(request, future) return future } @@ -397,14 +397,14 @@ class GIndicesAdminClient { // ANALYZE AnalyzeRequestBuilder prepareAnalyze(String index, String text) { - indicesAdminClient.prepareAnalyze(index, text); + indicesAdminClient.prepareAnalyze(index, text) } GActionFuture analyze(Closure c) { AnalyzeRequest request = new AnalyzeRequest() c.setDelegate request - c.resolveStrategy = gClient.resolveStrategy; - c.call(); + c.resolveStrategy = gClient.resolveStrategy + c.call() analyze(request) } @@ -417,14 +417,14 @@ class GIndicesAdminClient { // PUT INDEX TEMPLATE PutIndexTemplateRequestBuilder preparePutTemplate(String name) { - indicesAdminClient.preparePutTemplate(name); + indicesAdminClient.preparePutTemplate(name) } GActionFuture putTemplate(Closure c) { PutIndexTemplateRequest request = new PutIndexTemplateRequest() c.setDelegate request - c.resolveStrategy = gClient.resolveStrategy; - c.call(); + c.resolveStrategy = gClient.resolveStrategy + c.call() putTemplate(request) } @@ -437,14 +437,14 @@ class GIndicesAdminClient { // DELETE INDEX TEMPLATE DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) { - indicesAdminClient.prepareDeleteTemplate(name); + indicesAdminClient.prepareDeleteTemplate(name) } GActionFuture deleteTemplate(Closure c) { DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest() c.setDelegate request - c.resolveStrategy = gClient.resolveStrategy; - c.call(); + c.resolveStrategy = gClient.resolveStrategy + c.call() deleteTemplate(request) } diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy index 5cbc49e2fd6..71aa29ed4c4 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy @@ -33,9 +33,9 @@ import org.elasticsearch.common.xcontent.XContentType */ class GXContentBuilder { - static NODE_ELEMENT = "element" + static NODE_ELEMENT = 'element' - static int rootResolveStrategy = Closure.OWNER_FIRST; // the default in Closure + static int rootResolveStrategy = Closure.OWNER_FIRST // the default in Closure def root @@ -48,26 +48,26 @@ class GXContentBuilder { } String buildAsString(Closure c) { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON) def json = build(c) - builder.map(json); - return builder.string(); + builder.map(json) + return builder.string() } byte[] buildAsBytes(Closure c) { - return buildAsBytes(c, XContentType.JSON); + return buildAsBytes(c, XContentType.JSON) } byte[] buildAsBytes(Closure c, XContentType contentType) { - XContentBuilder builder = XContentFactory.contentBuilder(contentType); + XContentBuilder builder = XContentFactory.contentBuilder(contentType) def json = build(c) - builder.map(json); - return builder.copiedBytes(); + builder.map(json) + return builder.copiedBytes() } private buildRoot(Closure c) { c.delegate = this - c.resolveStrategy = rootResolveStrategy; + c.resolveStrategy = rootResolveStrategy root = [:] current = root def returnValue = c.call() @@ -85,7 +85,6 @@ class GXContentBuilder { def prev = current def list = [] try { - current = list c.call(list) } @@ -176,7 +175,6 @@ class GXContentBuilder { else { return it } - } current[propName] = value } @@ -188,5 +186,4 @@ class GXContentBuilder { def getProperty(String propName) { current[propName] } - -} \ No newline at end of file +} diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy index 7d496600ef6..fecefd95e8b 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy @@ -19,6 +19,7 @@ package org.elasticsearch.groovy.node +import org.elasticsearch.common.settings.Settings import org.elasticsearch.groovy.client.GClient import org.elasticsearch.node.Node @@ -27,26 +28,26 @@ import org.elasticsearch.node.Node */ class GNode { - final Node node; + final Node node - final GClient client; + final GClient client - def GNode(Node node) { - this.node = node; + GNode(Node node) { + this.node = node this.client = new GClient(node.client()) } /** * The settings that were used to create the node. */ - def getSettings() { - node.settings(); + Settings getSettings() { + node.settings() } /** * Start the node. If the node is already started, this method is no-op. */ - def start() { + GNode start() { node.start() this } @@ -54,15 +55,15 @@ class GNode { /** * Stops the node. If the node is already started, this method is no-op. */ - def stop() { + GNode stop() { node.stop() this } /** - * Closes the node (and {@link #stop} s if its running). + * Closes the node (and {@link #stop}s if it's running). */ - def close() { + GNode close() { node.close() this } diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy index 19d31997cca..75ab3eb551f 100644 --- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy +++ b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy @@ -27,43 +27,43 @@ import org.elasticsearch.node.Node import org.elasticsearch.node.internal.InternalNode /** - * The node builder allow to build a {@link GNode} instance. + * The node builder allow to build a {@link GNode} instance. * * @author kimchy (shay.banon) */ -public class GNodeBuilder { +class GNodeBuilder { - private final ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder(); + private final ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder() - private boolean loadConfigSettings = true; + private boolean loadConfigSettings = true - public static GNodeBuilder nodeBuilder() { + static GNodeBuilder nodeBuilder() { new GNodeBuilder() } - public ImmutableSettings.Builder getSettings() { - return settingsBuilder; + ImmutableSettings.Builder getSettings() { + settingsBuilder } - def settings(Settings.Builder settings) { + ImmutableSettings.Builder settings(Settings.Builder settings) { settingsBuilder.put(settings.build()) } - def settings(Settings settings) { + ImmutableSettings.Builder settings(Settings settings) { settingsBuilder.put(settings) } - def settings(Closure settings) { + ImmutableSettings.Builder settings(Closure settings) { byte[] settingsBytes = new GXContentBuilder().buildAsBytes(settings) settingsBuilder.put(new JsonSettingsLoader().load(settingsBytes)) } - def build() { + GNode build() { Node node = new InternalNode(settingsBuilder.build(), loadConfigSettings) new GNode(node) } - def node() { + GNode node() { build().start() } } diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy index c0e71f51c63..02654975d4d 100644 --- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy +++ b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy @@ -28,7 +28,7 @@ class GXContentBuilderTests extends GroovyTestCase { def builder = new GXContentBuilder() def result = builder.buildAsString { - rootprop = "something" + rootprop = 'something' } assertEquals '{"rootprop":"something"}', result.toString() @@ -39,7 +39,7 @@ class GXContentBuilderTests extends GroovyTestCase { def result = builder.buildAsString { categories = ['a', 'b', 'c'] - rootprop = "something" + rootprop = 'something' } assertEquals '{"categories":["a","b","c"],"rootprop":"something"}', result.toString() @@ -50,7 +50,7 @@ class GXContentBuilderTests extends GroovyTestCase { def result = builder.buildAsString { categories = ['a', 'b', 'c'] - rootprop = "something" + rootprop = 'something' test { subprop = 10 } @@ -64,7 +64,7 @@ class GXContentBuilderTests extends GroovyTestCase { def result = builder.buildAsString { categories = ['a', 'b', 'c'] - rootprop = "something" + rootprop = 'something' test = { subprop = 10 } @@ -77,9 +77,8 @@ class GXContentBuilderTests extends GroovyTestCase { def builder = new GXContentBuilder() def result = builder.buildAsString { categories = ['a', 'b', 'c'] - rootprop = "something" + rootprop = 'something' test subprop: 10, three: [1, 2, 3] - } assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10,"three":[1,2,3]}}', result.toString() @@ -89,7 +88,7 @@ class GXContentBuilderTests extends GroovyTestCase { void testArrayOfClosures() { def builder = new GXContentBuilder() def result = builder.buildAsString { - foo = [{ bar = "hello" }] + foo = [{ bar = 'hello' }] } assertEquals '{"foo":[{"bar":"hello"}]}', result.toString() @@ -125,7 +124,7 @@ class GXContentBuilderTests extends GroovyTestCase { def results = ['one', 'two', 'three'] def result = builder.buildAsString { - books = array {list -> + books = array { list -> for (b in results) { list << [title: b] } diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy index 034160af102..eab660a3dae 100644 --- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy +++ b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy @@ -43,7 +43,7 @@ class BuilderActionsTests { local = true } gateway { - type = "none" + type = 'none' } } @@ -55,45 +55,43 @@ class BuilderActionsTests { node.close() } - @Test void testSimpleOperations() { - def indexR = node.client.prepareIndex("test", "type1", "1").setSource({ - test = "value" + def indexR = node.client.prepareIndex('test', 'type1', '1').setSource({ + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } }).gexecute() - assertThat indexR.response.index, equalTo("test") - assertThat indexR.response.type, equalTo("type1") - assertThat indexR.response.id, equalTo("1") + assertThat indexR.response.index, equalTo('test') + assertThat indexR.response.type, equalTo('type1') + assertThat indexR.response.id, equalTo('1') node.client.admin.indices.refresh {}.actionGet() - def countR = node.client.prepareCount("test").setQuery({ - term(test: "value") - }).gexecute(); + def countR = node.client.prepareCount('test').setQuery({ + term(test: 'value') + }).gexecute() assertThat countR.response.count, equalTo(1l) - def searchR = node.client.prepareSearch("test").setQuery({ - term(test: "value") - }).gexecute(); + def searchR = node.client.prepareSearch('test').setQuery({ + term(test: 'value') + }).gexecute() assertThat searchR.response.hits.totalHits, equalTo(1l) - def delete = node.client.prepareDelete("test", "type1", "1").gexecute() - assertThat delete.response.index, equalTo("test") - assertThat delete.response.type, equalTo("type1") - assertThat delete.response.id, equalTo("1") + def delete = node.client.prepareDelete('test', 'type1', '1').gexecute() + assertThat delete.response.index, equalTo('test') + assertThat delete.response.type, equalTo('type1') + assertThat delete.response.id, equalTo('1') def refresh = node.client.admin.indices.refresh {} assertThat refresh.response.failedShards, equalTo(0) - def get = node.client.prepareGet("test", "type1", "1").gexecute() + def get = node.client.prepareGet('test', 'type1', '1').gexecute() assertThat get.response.exists, equalTo(false) - } -} \ No newline at end of file +} diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy index 1d9518972bc..e99e1a5c316 100644 --- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy +++ b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy @@ -46,7 +46,7 @@ class DifferentApiExecutionTests { local = true } gateway { - type = "none" + type = 'none' } } @@ -61,93 +61,93 @@ class DifferentApiExecutionTests { @Test void verifyDifferentApiExecutions() { def response = node.client.index(new IndexRequest( - index: "test", - type: "type1", - id: "1", + index: 'test', + type: 'type1', + id: '1', source: { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } })).response - assertThat response.index, equalTo("test") - assertThat response.type, equalTo("type1") - assertThat response.id, equalTo("1") + assertThat response.index, equalTo('test') + assertThat response.type, equalTo('type1') + assertThat response.id, equalTo('1') def refresh = node.client.admin.indices.refresh {} assertThat 0, equalTo(refresh.response.failedShards) def getR = node.client.get { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' } assertThat getR.response.exists, equalTo(true) - assertThat getR.response.index, equalTo("test") - assertThat getR.response.type, equalTo("type1") - assertThat getR.response.id, equalTo("1") + assertThat getR.response.index, equalTo('test') + assertThat getR.response.type, equalTo('type1') + assertThat getR.response.id, equalTo('1') assertThat getR.response.sourceAsString(), equalTo('{"test":"value","complex":{"value1":"value1","value2":"value2"}}') - assertThat getR.response.source.test, equalTo("value") - assertThat getR.response.source.complex.value1, equalTo("value1") + assertThat getR.response.source.test, equalTo('value') + assertThat getR.response.source.complex.value1, equalTo('value1') response = node.client.index({ - index = "test" - type = "type1" - id = "1" + index = 'test' + type = 'type1' + id = '1' source = { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } } }).response - assertThat response.index, equalTo("test") - assertThat response.type, equalTo("type1") - assertThat response.id, equalTo("1") + assertThat response.index, equalTo('test') + assertThat response.type, equalTo('type1') + assertThat response.id, equalTo('1') def indexR = node.client.index(indexRequest().with { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' source { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } } }) CountDownLatch latch = new CountDownLatch(1) - indexR.success = {IndexResponse responseX -> - assertThat responseX.index, equalTo("test") - assertThat indexR.response.index, equalTo("test") - assertThat responseX.type, equalTo("type1") - assertThat indexR.response.type, equalTo("type1") - assertThat response.id, equalTo("1") - assertThat indexR.response.id, equalTo("1") + indexR.success = { IndexResponse responseX -> + assertThat responseX.index, equalTo('test') + assertThat indexR.response.index, equalTo('test') + assertThat responseX.type, equalTo('type1') + assertThat indexR.response.type, equalTo('type1') + assertThat response.id, equalTo('1') + assertThat indexR.response.id, equalTo('1') latch.countDown() } latch.await() indexR = node.client.index { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' source { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } } } latch = new CountDownLatch(1) indexR.listener = { - assertThat indexR.response.index, equalTo("test") - assertThat indexR.response.type, equalTo("type1") - assertThat indexR.response.id, equalTo("1") + assertThat indexR.response.index, equalTo('test') + assertThat indexR.response.type, equalTo('type1') + assertThat indexR.response.id, equalTo('1') latch.countDown() } latch.await() diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy index f3cc4366f57..29e16fafd8e 100644 --- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy +++ b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy @@ -42,7 +42,7 @@ class SimpleActionsTests { local = true } gateway { - type = "none" + type = 'none' } } @@ -54,74 +54,73 @@ class SimpleActionsTests { node.close() } - @Test void testSimpleOperations() { def value1 = new org.elasticsearch.groovy.common.xcontent.GXContentBuilder().buildAsString { - something = "test" + something = 'test' } println value1 def indexR = node.client.index { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' source { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } } } - assertThat indexR.response.index, equalTo("test") - assertThat indexR.response.type, equalTo("type1") - assertThat indexR.response.id, equalTo("1") + assertThat indexR.response.index, equalTo('test') + assertThat indexR.response.type, equalTo('type1') + assertThat indexR.response.id, equalTo('1') def delete = node.client.delete { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' } - assertThat delete.response.index, equalTo("test") - assertThat delete.response.type, equalTo("type1") - assertThat delete.response.id, equalTo("1") + assertThat delete.response.index, equalTo('test') + assertThat delete.response.type, equalTo('type1') + assertThat delete.response.id, equalTo('1') def refresh = node.client.admin.indices.refresh {} assertThat refresh.response.failedShards, equalTo(0) def get = node.client.get { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' } assertThat get.response.exists, equalTo(false) indexR = node.client.index { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' source { - test = "value" + test = 'value' complex { - value1 = "value1" - value2 = "value2" + value1 = 'value1' + value2 = 'value2' } } } - assertThat indexR.response.index, equalTo("test") - assertThat indexR.response.type, equalTo("type1") - assertThat indexR.response.id, equalTo("1") + assertThat indexR.response.index, equalTo('test') + assertThat indexR.response.type, equalTo('type1') + assertThat indexR.response.id, equalTo('1') refresh = node.client.admin.indices.refresh {} assertThat refresh.response.failedShards, equalTo(0) def count = node.client.count { - indices "test" - types "type1" + indices 'test' + types 'type1' query { term { - test = "value" + test = 'value' } } } @@ -129,22 +128,22 @@ class SimpleActionsTests { assertThat count.response.count, equalTo(1l) def search = node.client.search { - indices "test" - types "type1" + indices 'test' + types 'type1' source { query { - term(test: "value") + term(test: 'value') } } } assertThat search.response.failedShards, equalTo(0) assertThat search.response.hits.totalHits, equalTo(1l) - assertThat search.response.hits[0].source.test, equalTo("value") + assertThat search.response.hits[0].source.test, equalTo('value') def deleteByQuery = node.client.deleteByQuery { - indices "test" + indices 'test' query { - term("test": "value") + term(test: 'value') } } assertThat deleteByQuery.response.indices.test.failedShards, equalTo(0) @@ -153,9 +152,9 @@ class SimpleActionsTests { assertThat refresh.response.failedShards, equalTo(0) get = node.client.get { - index "test" - type "type1" - id "1" + index 'test' + type 'type1' + id '1' } assertThat get.response.exists, equalTo(false) } diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy index 6dc4b4eb023..859611a7582 100644 --- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy +++ b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy @@ -29,13 +29,13 @@ import static org.elasticsearch.groovy.node.GNodeBuilder.* class GNodeBuilderTests extends GroovyTestCase { void testGNodeBuilder() { - GNodeBuilder nodeBuilder = nodeBuilder(); + GNodeBuilder nodeBuilder = nodeBuilder() nodeBuilder.settings { node { local = true } cluster { - name = "test" + name = 'test' } } GNode node = nodeBuilder.node()