Skip to content

Commit 115069e

Browse files
committed
renaming after elastic#127486
1 parent e71befa commit 115069e

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

test/framework/src/main/java/org/elasticsearch/bootstrap/TestBuildInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
import java.util.List;
1313

14-
record TestBuildInfo(String componentName, List<TestBuildInfoLocation> locations) {}
14+
record TestBuildInfo(String component, List<TestBuildInfoLocation> locations) {}

test/framework/src/main/java/org/elasticsearch/bootstrap/TestBuildInfoLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
package org.elasticsearch.bootstrap;
1111

12-
record TestBuildInfoLocation(String className, String moduleName) {}
12+
record TestBuildInfoLocation(String representativeClass, String module) {}

test/framework/src/main/java/org/elasticsearch/bootstrap/TestBuildInfoParser.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,43 @@ class TestBuildInfoParser {
3131
private static final ObjectParser<Builder, Void> PARSER = new ObjectParser<>("test_build_info", Builder::new);
3232
private static final ObjectParser<Location, Void> LOCATION_PARSER = new ObjectParser<>("location", Location::new);
3333
static {
34-
LOCATION_PARSER.declareString(Location::className, new ParseField("class"));
35-
LOCATION_PARSER.declareString(Location::moduleName, new ParseField("module"));
34+
LOCATION_PARSER.declareString(Location::representativeClass, new ParseField("representativeClass"));
35+
LOCATION_PARSER.declareString(Location::module, new ParseField("module"));
3636

37-
PARSER.declareString(Builder::name, new ParseField("name"));
37+
PARSER.declareString(Builder::component, new ParseField("component"));
3838
PARSER.declareObjectArray(Builder::locations, LOCATION_PARSER, new ParseField("locations"));
3939
}
4040

4141
private static class Location {
42-
private String className;
43-
private String moduleName;
42+
private String representativeClass;
43+
private String module;
4444

45-
public void moduleName(final String moduleName) {
46-
this.moduleName = moduleName;
45+
public void module(final String module) {
46+
this.module = module;
4747
}
4848

49-
public void className(final String className) {
50-
this.className = className;
49+
public void representativeClass(final String representativeClass) {
50+
this.representativeClass = representativeClass;
5151
}
5252
}
5353

5454
private static final class Builder {
55-
private String name;
55+
private String component;
5656
private List<Location> locations;
5757

58-
public void name(final String name) {
59-
this.name = name;
58+
public void component(final String component) {
59+
this.component = component;
6060
}
6161

6262
public void locations(final List<Location> locations) {
6363
this.locations = locations;
6464
}
6565

6666
TestBuildInfo build() {
67-
return new TestBuildInfo(name, locations.stream().map(l -> new TestBuildInfoLocation(l.className, l.moduleName)).toList());
67+
return new TestBuildInfo(
68+
component,
69+
locations.stream().map(l -> new TestBuildInfoLocation(l.representativeClass, l.module)).toList()
70+
);
6871
}
6972
}
7073

test/framework/src/main/java/org/elasticsearch/bootstrap/TestScopeResolver.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,30 @@ static Function<Class<?>, PolicyManager.PolicyScope> createScopeResolver(
4646
Map<String, PolicyManager.PolicyScope> scopeMap = new HashMap<>();
4747
for (var pluginBuildInfo : pluginsBuildInfo) {
4848
for (var location : pluginBuildInfo.locations()) {
49-
var codeSource = TestScopeResolver.class.getClassLoader().getResource(location.className());
49+
var codeSource = TestScopeResolver.class.getClassLoader().getResource(location.representativeClass());
5050
if (codeSource == null) {
51-
throw new IllegalArgumentException("Cannot locate class [" + location.className() + "]");
51+
throw new IllegalArgumentException("Cannot locate class [" + location.representativeClass() + "]");
5252
}
5353
try {
5454
scopeMap.put(
55-
getCodeSource(codeSource, location.className()),
56-
PolicyManager.PolicyScope.plugin(pluginBuildInfo.componentName(), location.moduleName())
55+
getCodeSource(codeSource, location.representativeClass()),
56+
PolicyManager.PolicyScope.plugin(pluginBuildInfo.component(), location.module())
5757
);
5858
} catch (MalformedURLException e) {
59-
throw new IllegalArgumentException("Cannot locate class [" + location.className() + "]", e);
59+
throw new IllegalArgumentException("Cannot locate class [" + location.representativeClass() + "]", e);
6060
}
6161
}
6262
}
6363

6464
for (var location : serverBuildInfo.locations()) {
65-
var classUrl = TestScopeResolver.class.getClassLoader().getResource(location.className());
65+
var classUrl = TestScopeResolver.class.getClassLoader().getResource(location.representativeClass());
6666
if (classUrl == null) {
67-
throw new IllegalArgumentException("Cannot locate class [" + location.className() + "]");
67+
throw new IllegalArgumentException("Cannot locate class [" + location.representativeClass() + "]");
6868
}
6969
try {
70-
scopeMap.put(getCodeSource(classUrl, location.className()), PolicyManager.PolicyScope.server(location.moduleName()));
70+
scopeMap.put(getCodeSource(classUrl, location.representativeClass()), PolicyManager.PolicyScope.server(location.module()));
7171
} catch (MalformedURLException e) {
72-
throw new IllegalArgumentException("Cannot locate class [" + location.className() + "]", e);
72+
throw new IllegalArgumentException("Cannot locate class [" + location.representativeClass() + "]", e);
7373
}
7474
}
7575

test/framework/src/test/java/org/elasticsearch/bootstrap/TestBuildInfoParserTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ public void testSimpleParsing() throws IOException {
2525

2626
var input = """
2727
{
28-
"name": "lang-painless",
28+
"component": "lang-painless",
2929
"locations": [
3030
{
31-
"class": "Location.class",
31+
"representativeClass": "Location.class",
3232
"module": "org.elasticsearch.painless"
3333
},
3434
{
35-
"class": "org/objectweb/asm/AnnotationVisitor.class",
35+
"representativeClass": "org/objectweb/asm/AnnotationVisitor.class",
3636
"module": "org.objectweb.asm"
3737
},
3838
{
39-
"class": "org/antlr/v4/runtime/ANTLRErrorListener.class",
39+
"representativeClass": "org/antlr/v4/runtime/ANTLRErrorListener.class",
4040
"module": "org.antlr.antlr4.runtime"
4141
},
4242
{
43-
"class": "org/objectweb/asm/commons/AdviceAdapter.class",
43+
"representativeClass": "org/objectweb/asm/commons/AdviceAdapter.class",
4444
"module": "org.objectweb.asm.commons"
4545
}
4646
]
@@ -49,19 +49,19 @@ public void testSimpleParsing() throws IOException {
4949

5050
try (var parser = XContentFactory.xContent(XContentType.JSON).createParser(XContentParserConfiguration.EMPTY, input)) {
5151
var testInfo = TestBuildInfoParser.fromXContent(parser);
52-
assertThat(testInfo.componentName(), is("lang-painless"));
52+
assertThat(testInfo.component(), is("lang-painless"));
5353
assertThat(
5454
testInfo.locations(),
5555
transformedItemsMatch(
56-
TestBuildInfoLocation::moduleName,
56+
TestBuildInfoLocation::module,
5757
contains("org.elasticsearch.painless", "org.objectweb.asm", "org.antlr.antlr4.runtime", "org.objectweb.asm.commons")
5858
)
5959
);
6060

6161
assertThat(
6262
testInfo.locations(),
6363
transformedItemsMatch(
64-
TestBuildInfoLocation::className,
64+
TestBuildInfoLocation::representativeClass,
6565
contains(
6666
"Location.class",
6767
"org/objectweb/asm/AnnotationVisitor.class",

0 commit comments

Comments
 (0)