Skip to content

Commit 50da66b

Browse files
[8.x] Move AbstractBWCSerializationTestCase To General Test Framework (#113907) (#113977)
* Move AbstractBWCSerializationTestCase To General Test Framework (#113907) (cherry picked from commit a5d033b) # Conflicts: # x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/action/PutAnalyticsCollectionResponseBWCSerializingTests.java * Remove unused import --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent 01a4c2a commit 50da66b

File tree

93 files changed

+131
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+131
-109
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
7-
package org.elasticsearch.xpack.core.ml;
9+
10+
package org.elasticsearch.test;
811

912
import org.elasticsearch.TransportVersion;
1013
import org.elasticsearch.common.io.stream.Writeable;
11-
import org.elasticsearch.test.AbstractXContentSerializingTestCase;
1214
import org.elasticsearch.xcontent.ToXContent;
1315

1416
import java.io.IOException;
1517
import java.util.List;
1618

17-
import static org.elasticsearch.xpack.core.ml.AbstractBWCWireSerializationTestCase.DEFAULT_BWC_VERSIONS;
19+
import static org.elasticsearch.test.BWCVersions.DEFAULT_BWC_VERSIONS;
1820

1921
public abstract class AbstractBWCSerializationTestCase<T extends Writeable & ToXContent> extends AbstractXContentSerializingTestCase<T> {
2022

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.test;
11+
12+
import org.elasticsearch.TransportVersion;
13+
import org.elasticsearch.TransportVersions;
14+
15+
import java.util.Collections;
16+
import java.util.List;
17+
18+
import static org.elasticsearch.KnownTransportVersions.ALL_VERSIONS;
19+
20+
public final class BWCVersions {
21+
private BWCVersions() {}
22+
23+
public static List<TransportVersion> getAllBWCVersions() {
24+
int minCompatVersion = Collections.binarySearch(ALL_VERSIONS, TransportVersions.MINIMUM_COMPATIBLE);
25+
return ALL_VERSIONS.subList(minCompatVersion, ALL_VERSIONS.size());
26+
}
27+
28+
public static final List<TransportVersion> DEFAULT_BWC_VERSIONS = getAllBWCVersions();
29+
}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/AbstractBWCWireSerializationTestCase.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,17 @@
77
package org.elasticsearch.xpack.core.ml;
88

99
import org.elasticsearch.TransportVersion;
10-
import org.elasticsearch.TransportVersions;
1110
import org.elasticsearch.common.io.stream.Writeable;
1211
import org.elasticsearch.core.Strings;
1312
import org.elasticsearch.test.AbstractWireSerializingTestCase;
1413

1514
import java.io.IOException;
16-
import java.util.Collections;
1715
import java.util.List;
1816

19-
import static org.elasticsearch.KnownTransportVersions.ALL_VERSIONS;
17+
import static org.elasticsearch.test.BWCVersions.DEFAULT_BWC_VERSIONS;
2018

2119
public abstract class AbstractBWCWireSerializationTestCase<T extends Writeable> extends AbstractWireSerializingTestCase<T> {
2220

23-
public static List<TransportVersion> getAllBWCVersions() {
24-
int minCompatVersion = Collections.binarySearch(ALL_VERSIONS, TransportVersions.MINIMUM_COMPATIBLE);
25-
return ALL_VERSIONS.subList(minCompatVersion, ALL_VERSIONS.size());
26-
}
27-
28-
static final List<TransportVersion> DEFAULT_BWC_VERSIONS = getAllBWCVersions();
29-
3021
/**
3122
* Returns the expected instance if serialized from the given version.
3223
*/

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/AbstractChunkedBWCSerializationTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.io.IOException;
1616
import java.util.List;
1717

18-
import static org.elasticsearch.xpack.core.ml.AbstractBWCWireSerializationTestCase.DEFAULT_BWC_VERSIONS;
18+
import static org.elasticsearch.test.BWCVersions.DEFAULT_BWC_VERSIONS;
1919

2020
public abstract class AbstractChunkedBWCSerializationTestCase<T extends ChunkedToXContent & Writeable> extends
2121
AbstractChunkedSerializingTestCase<T> {

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsConfigTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.rest.RestStatus;
2626
import org.elasticsearch.search.SearchModule;
2727
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
28+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
2829
import org.elasticsearch.xcontent.NamedXContentRegistry;
2930
import org.elasticsearch.xcontent.ObjectParser;
3031
import org.elasticsearch.xcontent.ToXContent;
@@ -34,7 +35,6 @@
3435
import org.elasticsearch.xcontent.XContentParserConfiguration;
3536
import org.elasticsearch.xcontent.XContentType;
3637
import org.elasticsearch.xcontent.json.JsonXContent;
37-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
3838
import org.elasticsearch.xpack.core.ml.MlConfigVersion;
3939
import org.elasticsearch.xpack.core.ml.dataframe.analyses.Classification;
4040
import org.elasticsearch.xpack.core.ml.dataframe.analyses.ClassificationTests;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsDestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import org.elasticsearch.TransportVersion;
1010
import org.elasticsearch.common.io.stream.Writeable;
11+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
1112
import org.elasticsearch.xcontent.XContentParser;
12-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
1313

1414
import java.io.IOException;
1515

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import org.elasticsearch.index.query.QueryBuilders;
1515
import org.elasticsearch.search.SearchModule;
1616
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
17+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
1718
import org.elasticsearch.xcontent.NamedXContentRegistry;
1819
import org.elasticsearch.xcontent.XContentParser;
19-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
2020
import org.elasticsearch.xpack.core.ml.utils.QueryProvider;
2121

2222
import java.io.IOException;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParamsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import org.elasticsearch.ElasticsearchStatusException;
1010
import org.elasticsearch.TransportVersion;
1111
import org.elasticsearch.common.io.stream.Writeable;
12+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
1213
import org.elasticsearch.xcontent.ConstructingObjectParser;
1314
import org.elasticsearch.xcontent.XContentParser;
14-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
1515

1616
import java.io.IOException;
1717
import java.util.HashMap;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import org.elasticsearch.index.mapper.KeywordFieldMapper;
2121
import org.elasticsearch.index.mapper.NumberFieldMapper;
2222
import org.elasticsearch.search.SearchModule;
23+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
2324
import org.elasticsearch.xcontent.DeprecationHandler;
2425
import org.elasticsearch.xcontent.NamedXContentRegistry;
2526
import org.elasticsearch.xcontent.ToXContent;
2627
import org.elasticsearch.xcontent.XContentBuilder;
2728
import org.elasticsearch.xcontent.XContentParser;
2829
import org.elasticsearch.xcontent.XContentType;
2930
import org.elasticsearch.xcontent.json.JsonXContent;
30-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
3131
import org.elasticsearch.xpack.core.ml.MlConfigVersion;
3232
import org.elasticsearch.xpack.core.ml.inference.MlInferenceNamedXContentProvider;
3333
import org.elasticsearch.xpack.core.ml.inference.preprocessing.FrequencyEncodingTests;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/OutlierDetectionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.elasticsearch.TransportVersion;
1010
import org.elasticsearch.common.io.stream.Writeable;
1111
import org.elasticsearch.index.mapper.NumberFieldMapper;
12+
import org.elasticsearch.test.AbstractBWCSerializationTestCase;
1213
import org.elasticsearch.xcontent.XContentParser;
13-
import org.elasticsearch.xpack.core.ml.AbstractBWCSerializationTestCase;
1414

1515
import java.io.IOException;
1616
import java.util.Collections;

0 commit comments

Comments
 (0)