cleanup tests

- make DeleteActionTests pass
- remove getType from LifecycleType
This commit is contained in:
Tal Levy 2018-04-11 18:28:46 -07:00
parent 7f4801f03c
commit c1b00d0154
7 changed files with 4 additions and 22 deletions

View File

@ -53,7 +53,7 @@ public class DeleteAction implements LifecycleAction {
@Override @Override
public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey) { public List<Step> 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)); return Collections.singletonList(new DeleteStep(deleteStepKey, nextStepKey, client));
} }

View File

@ -11,6 +11,7 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
public class DeleteStep extends AsyncActionStep { public class DeleteStep extends AsyncActionStep {
public static final String NAME = "delete";
public DeleteStep(StepKey key, StepKey nextStepKey, Client client) { public DeleteStep(StepKey key, StepKey nextStepKey, Client client) {
super(key, nextStepKey, client); super(key, nextStepKey, client);

View File

@ -129,7 +129,7 @@ public class LifecyclePolicy extends AbstractDiffable<LifecyclePolicy>
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(); builder.startObject();
builder.field(TYPE_FIELD.getPreferredName(), type.getType()); builder.field(TYPE_FIELD.getPreferredName(), type.getWriteableName());
builder.startObject(PHASES_FIELD.getPreferredName()); builder.startObject(PHASES_FIELD.getPreferredName());
for (Phase phase : phases.values()) { for (Phase phase : phases.values()) {
builder.field(phase.getName(), phase); builder.field(phase.getName(), phase);

View File

@ -31,13 +31,4 @@ public interface LifecycleType extends NamedWriteable {
* if a specific phase or lack of a specific phase is invalid. * if a specific phase or lack of a specific phase is invalid.
*/ */
void validate(Collection<Phase> phases); void validate(Collection<Phase> 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();
} }

View File

@ -54,11 +54,6 @@ public class TimeseriesLifecycleType implements LifecycleType {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
} }
@Override
public String getType() {
return TYPE;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return TYPE; return TYPE;

View File

@ -38,7 +38,7 @@ public class DeleteActionTests extends AbstractSerializingTestCase<DeleteAction>
List<Step> steps = action.toSteps(null, phase, nextStepKey); List<Step> steps = action.toSteps(null, phase, nextStepKey);
assertNotNull(steps); assertNotNull(steps);
assertEquals(1, steps.size()); 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); DeleteStep firstStep = (DeleteStep) steps.get(0);
assertEquals(expectedFirstStepKey, firstStep.getKey()); assertEquals(expectedFirstStepKey, firstStep.getKey());
assertEquals(nextStepKey, firstStep.getNextStepKey()); assertEquals(nextStepKey, firstStep.getNextStepKey());

View File

@ -25,11 +25,6 @@ public class TestLifecycleType implements LifecycleType {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
} }
@Override
public String getType() {
return TYPE;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return TYPE; return TYPE;