From d66a63ed7a13fa9427c6158772c3819f938b1a83 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Wed, 3 Oct 2018 15:39:21 -0600 Subject: [PATCH] [HLRC] Update Stop & Start ILM APIs to use Validatable (#34242) Convert the Stop and Start request objects to inherit from the preferred Validatable instead of ActionRequest. --- .../client/indexlifecycle/StartILMRequest.java | 10 ++-------- .../client/indexlifecycle/StopILMRequest.java | 10 ++-------- .../client/RequestConvertersTests.java | 8 ++++---- .../indexlifecycle/StartILMRequestTests.java | 17 ++++++++--------- .../indexlifecycle/StopILMRequestTests.java | 17 ++++++++--------- 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StartILMRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StartILMRequest.java index f6064c44901..84cc844a92a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StartILMRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StartILMRequest.java @@ -19,19 +19,13 @@ package org.elasticsearch.client.indexlifecycle; -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.support.master.AcknowledgedRequest; +import org.elasticsearch.client.TimedRequest; -public class StartILMRequest extends AcknowledgedRequest { +public class StartILMRequest extends TimedRequest { public StartILMRequest() { } - @Override - public ActionRequestValidationException validate() { - return null; - } - @Override public int hashCode() { return 64; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StopILMRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StopILMRequest.java index 4f561109318..1695fc0dd7a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StopILMRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/StopILMRequest.java @@ -19,19 +19,13 @@ package org.elasticsearch.client.indexlifecycle; -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.support.master.AcknowledgedRequest; +import org.elasticsearch.client.TimedRequest; -public class StopILMRequest extends AcknowledgedRequest { +public class StopILMRequest extends TimedRequest { public StopILMRequest() { } - @Override - public ActionRequestValidationException validate() { - return null; - } - @Override public int hashCode() { return 75; diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index 8f8311ab46a..89f2aa58b38 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -1530,8 +1530,8 @@ public class RequestConvertersTests extends ESTestCase { public void testStartILM() throws Exception { StartILMRequest req = new StartILMRequest(); Map expectedParams = new HashMap<>(); - setRandomMasterTimeout(req, expectedParams); - setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); + setRandomMasterTimeout(req::setMasterTimeout, StartILMRequest.DEFAULT_MASTER_TIMEOUT, expectedParams); + setRandomTimeoutTimeValue(req::setTimeout, StartILMRequest.DEFAULT_TIMEOUT, expectedParams); Request request = RequestConverters.startILM(req); assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME)); @@ -1542,8 +1542,8 @@ public class RequestConvertersTests extends ESTestCase { public void testStopILM() throws Exception { StopILMRequest req = new StopILMRequest(); Map expectedParams = new HashMap<>(); - setRandomMasterTimeout(req, expectedParams); - setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); + setRandomMasterTimeout(req::setMasterTimeout, StopILMRequest.DEFAULT_MASTER_TIMEOUT, expectedParams); + setRandomTimeoutTimeValue(req::setTimeout, StopILMRequest.DEFAULT_TIMEOUT, expectedParams); Request request = RequestConverters.stopILM(req); assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StartILMRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StartILMRequestTests.java index f9da5d49e06..449ef7d1678 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StartILMRequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StartILMRequestTests.java @@ -19,23 +19,22 @@ package org.elasticsearch.client.indexlifecycle; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.EqualsHashCodeTestUtils; -public class StartILMRequestTests extends AbstractStreamableTestCase { +public class StartILMRequestTests extends ESTestCase { - @Override - protected StartILMRequest createBlankInstance() { - return new StartILMRequest(); - } - - @Override protected StartILMRequest createTestInstance() { return new StartILMRequest(); } public void testValidate() { StartILMRequest request = createTestInstance(); - assertNull(request.validate()); + assertFalse(request.validate().isPresent()); + } + + public void testEqualsAndHashcode() { + EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(), (original) -> createTestInstance()); } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StopILMRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StopILMRequestTests.java index 8f1a3756c8a..f1618f3f0f0 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StopILMRequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/StopILMRequestTests.java @@ -19,23 +19,22 @@ package org.elasticsearch.client.indexlifecycle; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.EqualsHashCodeTestUtils; -public class StopILMRequestTests extends AbstractStreamableTestCase { +public class StopILMRequestTests extends ESTestCase { - @Override - protected StopILMRequest createBlankInstance() { - return new StopILMRequest(); - } - - @Override protected StopILMRequest createTestInstance() { return new StopILMRequest(); } public void testValidate() { StopILMRequest request = createTestInstance(); - assertNull(request.validate()); + assertFalse(request.validate().isPresent()); + } + + public void testEqualsAndHashcode() { + EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(), (original) -> createTestInstance()); } }