When a command runs a ComponentFlow with two sequential steps and the test supplies two queued inputs via ShellInputProvider.Builder#withInput(String), the flow throws a NoSuchElementException on the second step's context key — regardless of the value supplied (tested with "y", "yes", "true").
Steps to reproduce
Command under test:
```java
@component
public class ExampleCommand {
private final ComponentFlow.Builder builder;
public ExampleCommand(ComponentFlow.Builder builder) {
this.builder = builder;
}
@Command(name = "example")
public String example() {
ComponentFlow flow = builder.clone().reset()
.withStringInput("reason")
.name("Reason:")
.and()
.withConfirmationInput("confirm")
.name("Confirm?")
.and()
.build();
ComponentFlow.ComponentFlowResult result = flow.run();
boolean confirmed = result.getContext().get("confirm");
return confirmed ? "Confirmed" : "Cancelled";
}
}
```
Test:
```java
@ShellTest
@ContextConfiguration(classes = ExampleApplication.class)
class ExampleCommandTest {
@Test
void testExample(@Autowired ShellTestClient client) throws Exception {
ShellInputProvider provider = ShellInputProvider.providerFor("example")
.withInput("some reason")
.withInput("true")
.build();
ShellScreen screen = client.sendCommand(provider);
ShellAssertions.assertThat(screen).containsText("Confirmed");
}
}
```
Expected behavior
The queued inputs are consumed sequentially by the ComponentFlow steps, and the flow completes with confirm = true.
Actual behavior
```
java.util.NoSuchElementException: Context does not contain key: confirm
at org.springframework.shell.jline.tui.component.context.BaseComponentContext.get(BaseComponentContext.java:44)
at ExampleCommand.example(ExampleCommand.java:...)
...
```
The exception is identical regardless of the value queued via withInput(...) (tried "y", "yes", "true"), which suggests the input is never reaching the ComponentFlow/ConfirmationInput reading mechanism at all, rather than being rejected as an invalid value.
Is ComponentFlow end-to-end testing currently expected to be unsupported in 4.0.3, or is there a recommended workaround I'm missing?
When a command runs a
ComponentFlowwith two sequential steps and the test supplies two queued inputs viaShellInputProvider.Builder#withInput(String), the flow throws aNoSuchElementExceptionon the second step's context key — regardless of the value supplied (tested with"y","yes","true").Steps to reproduce
Command under test:
```java
@component
public class ExampleCommand {
}
```
Test:
```java
@ShellTest
@ContextConfiguration(classes = ExampleApplication.class)
class ExampleCommandTest {
}
```
Expected behavior
The queued inputs are consumed sequentially by the
ComponentFlowsteps, and the flow completes withconfirm = true.Actual behavior
```
java.util.NoSuchElementException: Context does not contain key: confirm
at org.springframework.shell.jline.tui.component.context.BaseComponentContext.get(BaseComponentContext.java:44)
at ExampleCommand.example(ExampleCommand.java:...)
...
```
The exception is identical regardless of the value queued via
withInput(...)(tried"y","yes","true"), which suggests the input is never reaching theComponentFlow/ConfirmationInputreading mechanism at all, rather than being rejected as an invalid value.Is
ComponentFlowend-to-end testing currently expected to be unsupported in 4.0.3, or is there a recommended workaround I'm missing?