|
1 | 1 | /*
|
2 |
| - * Copyright 2022 the original author or authors. |
| 2 | + * Copyright 2022-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -181,4 +181,30 @@ public void testResultUserInputYes() throws InterruptedException, IOException {
|
181 | 181 | assertThat(run1Context.getResultValue()).isNotNull();
|
182 | 182 | assertThat(run1Context.getResultValue()).isTrue();
|
183 | 183 | }
|
| 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 | + } |
184 | 210 | }
|
0 commit comments