diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadataDiffableSerializationTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadataDiffableSerializationTests.java index af504d88beb..bdd2b4f54df 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadataDiffableSerializationTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadataDiffableSerializationTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractDiffableSerializationTestCase; @@ -29,12 +28,12 @@ public class AutoscalingMetadataDiffableSerializationTests extends AbstractDiffa @Override protected NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables()); + return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry(); } @Override protected NamedXContentRegistry xContentRegistry() { - return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent()); + return AutoscalingTestCase.getAutoscalingXContentRegistry(); } @Override diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java index 1c2a342e80e..039b3d868e8 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java @@ -7,6 +7,9 @@ package org.elasticsearch.xpack.autoscaling; import org.elasticsearch.common.Randomness; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.autoscaling.decision.AlwaysAutoscalingDecider; import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecider; @@ -118,4 +121,12 @@ public abstract class AutoscalingTestCase extends ESTestCase { return new AutoscalingMetadata(policies); } + public static NamedWriteableRegistry getAutoscalingNamedWriteableRegistry() { + return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables()); + } + + public static NamedXContentRegistry getAutoscalingXContentRegistry() { + return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent()); + } + } diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicyMetadataDiffableSerializationTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicyMetadataDiffableSerializationTests.java index 931e5da2478..0953cc81536 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicyMetadataDiffableSerializationTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicyMetadataDiffableSerializationTests.java @@ -10,11 +10,10 @@ import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.Diff; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractDiffableSerializationTestCase; -import org.elasticsearch.xpack.autoscaling.Autoscaling; +import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase; import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.mutateAutoscalingPolicy; import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingPolicyOfName; @@ -25,12 +24,12 @@ public class AutoscalingPolicyMetadataDiffableSerializationTests extends Abstrac @Override protected NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables()); + return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry(); } @Override protected NamedXContentRegistry xContentRegistry() { - return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent()); + return AutoscalingTestCase.getAutoscalingXContentRegistry(); } @Override diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicySerializingTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicySerializingTests.java index 0d49ccc4e21..b7f9bab7f4b 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicySerializingTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicySerializingTests.java @@ -8,11 +8,10 @@ package org.elasticsearch.xpack.autoscaling.policy; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractSerializingTestCase; -import org.elasticsearch.xpack.autoscaling.Autoscaling; +import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase; import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.mutateAutoscalingPolicy; import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingPolicyOfName; @@ -23,12 +22,12 @@ public class AutoscalingPolicySerializingTests extends AbstractSerializingTestCa @Override protected NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables()); + return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry(); } @Override protected NamedXContentRegistry xContentRegistry() { - return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent()); + return AutoscalingTestCase.getAutoscalingXContentRegistry(); } @Override