Browse Source

added Configuration Menu no Exit after wrong Input

feature-vault
fdai6352 3 years ago
parent
commit
6fa8c74313
  1. 1
      src/main/java/Vault.java
  2. 14
      src/test/java/VaultTest.java

1
src/main/java/Vault.java

@ -34,7 +34,6 @@ public class Vault implements VaultInterface {
if (input.equals("e")) {
config = false;
}
}

14
src/test/java/VaultTest.java

@ -55,6 +55,20 @@ public class VaultTest {
assertFalse(vlt.config);
}
@Test
void doNotExitConfigAfterWrongInput() {
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8));
vlt.configure();
assertTrue(vlt.config);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = getEmptyStringInputStream();
vlt.outputS = outputStream;
assertThrowsExactly(NoSuchElementException.class, () -> vlt.configure());
assertTrue(outputStream.toString().startsWith("Configure:"));
}
private ByteArrayInputStream getEmptyStringInputStream() {

Loading…
Cancel
Save