diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionAction.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionAction.java index 9c2bc85b3d6..3e0f18f0e6c 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionAction.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionAction.java @@ -51,6 +51,18 @@ public class GetAutoscalingDecisionAction extends ActionType decisions; + public Collection decisions() { + return decisions; + } + public AutoscalingDecisions(final Collection decisions) { Objects.requireNonNull(decisions); if (decisions.isEmpty()) { diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionRequestWireSerializingTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionRequestWireSerializingTests.java new file mode 100644 index 00000000000..cae49c316f6 --- /dev/null +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionRequestWireSerializingTests.java @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.autoscaling.action; + +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; + +public class GetAutoscalingDecisionActionRequestWireSerializingTests extends AbstractWireSerializingTestCase< + GetAutoscalingDecisionAction.Request> { + + @Override + protected Writeable.Reader instanceReader() { + return GetAutoscalingDecisionAction.Request::new; + } + + @Override + protected GetAutoscalingDecisionAction.Request createTestInstance() { + return new GetAutoscalingDecisionAction.Request(); + } + +} diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionResponseWireSerializingTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionResponseWireSerializingTests.java new file mode 100644 index 00000000000..68db311fe67 --- /dev/null +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionResponseWireSerializingTests.java @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.autoscaling.action; + +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; +import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisions; + +import java.util.Collections; +import java.util.SortedMap; +import java.util.TreeMap; + +import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingDecisions; + +public class GetAutoscalingDecisionActionResponseWireSerializingTests extends AbstractWireSerializingTestCase< + GetAutoscalingDecisionAction.Response> { + + @Override + protected Writeable.Reader instanceReader() { + return GetAutoscalingDecisionAction.Response::new; + } + + @Override + protected GetAutoscalingDecisionAction.Response createTestInstance() { + final int numberOfPolicies = randomIntBetween(1, 8); + final SortedMap decisions = new TreeMap<>(); + for (int i = 0; i < numberOfPolicies; i++) { + decisions.put(randomAlphaOfLength(8), randomAutoscalingDecisions()); + } + return new GetAutoscalingDecisionAction.Response(Collections.unmodifiableSortedMap(decisions)); + } + +}