From c1b00d015488d71f43e05795ca642910ea4aac45 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Wed, 11 Apr 2018 18:28:46 -0700 Subject: [PATCH] cleanup tests - make DeleteActionTests pass - remove getType from LifecycleType --- .../xpack/core/indexlifecycle/DeleteAction.java | 2 +- .../xpack/core/indexlifecycle/DeleteStep.java | 1 + .../xpack/core/indexlifecycle/LifecyclePolicy.java | 2 +- .../xpack/core/indexlifecycle/LifecycleType.java | 9 --------- .../core/indexlifecycle/TimeseriesLifecycleType.java | 5 ----- .../xpack/core/indexlifecycle/DeleteActionTests.java | 2 +- .../xpack/core/indexlifecycle/TestLifecycleType.java | 5 ----- 7 files changed, 4 insertions(+), 22 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java index 4068e8c6a39..6b613ddab3b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java @@ -53,7 +53,7 @@ public class DeleteAction implements LifecycleAction { @Override public List toSteps(Client client, String phase, Step.StepKey nextStepKey) { - Step.StepKey deleteStepKey = new Step.StepKey(phase, NAME, "delete-step"); + Step.StepKey deleteStepKey = new Step.StepKey(phase, NAME, DeleteStep.NAME); return Collections.singletonList(new DeleteStep(deleteStepKey, nextStepKey, client)); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteStep.java index 75e53302c57..a9273dcf9ef 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteStep.java @@ -11,6 +11,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; public class DeleteStep extends AsyncActionStep { + public static final String NAME = "delete"; public DeleteStep(StepKey key, StepKey nextStepKey, Client client) { super(key, nextStepKey, client); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicy.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicy.java index 7a03d66ca2d..1e1432b6ec3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicy.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicy.java @@ -129,7 +129,7 @@ public class LifecyclePolicy extends AbstractDiffable @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - builder.field(TYPE_FIELD.getPreferredName(), type.getType()); + builder.field(TYPE_FIELD.getPreferredName(), type.getWriteableName()); builder.startObject(PHASES_FIELD.getPreferredName()); for (Phase phase : phases.values()) { builder.field(phase.getName(), phase); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecycleType.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecycleType.java index fec5d9571b5..2c4c18199f8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecycleType.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/LifecycleType.java @@ -31,13 +31,4 @@ public interface LifecycleType extends NamedWriteable { * if a specific phase or lack of a specific phase is invalid. */ void validate(Collection phases); - - /** - * Each {@link LifecyclePolicy} has a specific type to differentiate - * themselves. Every implementation is responsible to providing its specific - * type. - * - * @return the {@link LifecyclePolicy} type. - */ - String getType(); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/TimeseriesLifecycleType.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/TimeseriesLifecycleType.java index 337f2778b5b..89056cac202 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/TimeseriesLifecycleType.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/TimeseriesLifecycleType.java @@ -54,11 +54,6 @@ public class TimeseriesLifecycleType implements LifecycleType { public void writeTo(StreamOutput out) throws IOException { } - @Override - public String getType() { - return TYPE; - } - @Override public String getWriteableName() { return TYPE; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteActionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteActionTests.java index 919df2b4f73..6ae6f0c867a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteActionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteActionTests.java @@ -38,7 +38,7 @@ public class DeleteActionTests extends AbstractSerializingTestCase List steps = action.toSteps(null, phase, nextStepKey); assertNotNull(steps); assertEquals(1, steps.size()); - StepKey expectedFirstStepKey = new StepKey(phase, AllocateAction.NAME, AllocateAction.NAME); + StepKey expectedFirstStepKey = new StepKey(phase, DeleteAction.NAME, DeleteStep.NAME); DeleteStep firstStep = (DeleteStep) steps.get(0); assertEquals(expectedFirstStepKey, firstStep.getKey()); assertEquals(nextStepKey, firstStep.getNextStepKey()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java index f7187a53349..1ca6de65ee7 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java @@ -25,11 +25,6 @@ public class TestLifecycleType implements LifecycleType { public void writeTo(StreamOutput out) throws IOException { } - @Override - public String getType() { - return TYPE; - } - @Override public String getWriteableName() { return TYPE;