Skip to content

Commit 3ad6077

Browse files
Fixing tests
1 parent ac4da6a commit 3ad6077

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/common/ValidatingSubstitutorTests.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,38 @@ public void testReplace_ThrowsException_WhenPlaceHolderStillExists() {
3737
var sub = new ValidatingSubstitutor(Map.of("some_key", "value", "key2", "value2"), "${", "}");
3838
var exception = expectThrows(IllegalStateException.class, () -> sub.replace("super:${key}", "setting"));
3939

40-
assertThat(exception.getMessage(), is("Found placeholder [${key}] in field [setting] after replacement call"));
40+
assertThat(
41+
exception.getMessage(),
42+
is(
43+
"Found placeholder [${key}] in field [setting] after replacement call, "
44+
+ "please check that all templates have a corresponding field definition."
45+
)
46+
);
4147
}
4248
// only reports the first placeholder pattern
4349
{
4450
var sub = new ValidatingSubstitutor(Map.of("some_key", "value", "some_key2", "value2"), "${", "}");
4551
var exception = expectThrows(IllegalStateException.class, () -> sub.replace("super, ${key}, ${key2}", "setting"));
4652

47-
assertThat(exception.getMessage(), is("Found placeholder [${key}] in field [setting] after replacement call"));
53+
assertThat(
54+
exception.getMessage(),
55+
is(
56+
"Found placeholder [${key}] in field [setting] after replacement call, "
57+
+ "please check that all templates have a corresponding field definition."
58+
)
59+
);
4860
}
4961
{
5062
var sub = new ValidatingSubstitutor(Map.of("some_key", "value", "key2", "value2"), "${", "}");
5163
var exception = expectThrows(IllegalStateException.class, () -> sub.replace("super:${ \\/\tkey\"}", "setting"));
5264

53-
assertThat(exception.getMessage(), is("Found placeholder [${ \\/\tkey\"}] in field [setting] after replacement call"));
65+
assertThat(
66+
exception.getMessage(),
67+
is(
68+
"Found placeholder [${ \\/\tkey\"}] in field [setting] after replacement call,"
69+
+ " please check that all templates have a corresponding field definition."
70+
)
71+
);
5472
}
5573
}
5674
}

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/custom/request/CustomRequestTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,13 @@ public void testCreateRequest_IgnoresNonStringFields_ForStringParams() throws IO
270270

271271
var request = new CustomRequest(null, List.of("abc", "123"), model);
272272
var exception = expectThrows(IllegalStateException.class, request::createHttpRequest);
273-
assertThat(exception.getMessage(), is("Found placeholder [${task.key}] in field [header.Accept] after replacement call"));
273+
assertThat(
274+
exception.getMessage(),
275+
is(
276+
"Found placeholder [${task.key}] in field [header.Accept] after replacement call, "
277+
+ "please check that all templates have a corresponding field definition."
278+
)
279+
);
274280
}
275281

276282
public void testCreateRequest_ThrowsException_ForInvalidUrl() {

0 commit comments

Comments
 (0)