Skip to content

Commit de08935

Browse files
committed
Fix ConfirmationInput template message
- Fix confirmation-input-default.stg to use correct style names in format. - Backport #690 - Fixes #692
1 parent 3c09084 commit de08935

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

spring-shell-core/src/main/resources/org/springframework/shell/component/confirmation-input-default.stg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// message
22
message(model) ::= <%
33
<if(model.message && model.hasMessageLevelError)>
4-
<(">>>"); format="level-error"> <model.message; format="level-error">
4+
<({<figures.error>}); format="style-level-error"> <model.message; format="style-level-error">
55
<elseif(model.message && model.hasMessageLevelWarn)>
6-
<(">>"); format="level-warn"> <model.message; format="level-warn">
6+
<({<figures.warning>}); format="style-level-warn"> <model.message; format="style-level-warn">
77
<elseif(model.message && model.hasMessageLevelInfo)>
8-
<(">"); format="level-info"> <model.message; format="level-info">
8+
<({<figures.info>}); format="style-level-info"> <model.message; format="style-level-info">
99
<endif>
1010
%>
1111

spring-shell-core/src/test/java/org/springframework/shell/component/ConfirmationInputTests.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -181,4 +181,30 @@ public void testResultUserInputYes() throws InterruptedException, IOException {
181181
assertThat(run1Context.getResultValue()).isNotNull();
182182
assertThat(run1Context.getResultValue()).isTrue();
183183
}
184+
185+
@Test
186+
public void testResultUserInputInvalidInput() throws InterruptedException, IOException {
187+
ComponentContext<?> empty = ComponentContext.empty();
188+
ConfirmationInput component1 = new ConfirmationInput(getTerminal(), "component1");
189+
component1.setResourceLoader(new DefaultResourceLoader());
190+
component1.setTemplateExecutor(getTemplateExecutor());
191+
192+
service.execute(() -> {
193+
ConfirmationInputContext run1Context = component1.run(empty);
194+
result1.set(run1Context);
195+
latch1.countDown();
196+
});
197+
198+
TestBuffer testBuffer = new TestBuffer().append("x").cr();
199+
write(testBuffer.getBytes());
200+
201+
latch1.await(2, TimeUnit.SECONDS);
202+
203+
assertThat(consoleOut()).contains("input is invalid");
204+
205+
ConfirmationInputContext run1Context = result1.get();
206+
207+
assertThat(run1Context).isNotNull();
208+
assertThat(run1Context.getResultValue()).isNull();
209+
}
184210
}

0 commit comments

Comments
 (0)