From 1c6d2148f2353073c6b8b824d6756e49b86fb04d Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Sat, 5 Feb 2022 20:19:09 +0100 Subject: [PATCH] added Configuration Menu exit --- src/main/java/Vault.java | 11 ++++++++++- src/test/java/VaultTest.java | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index d90d0e2..7f29b23 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -6,6 +6,7 @@ import java.util.Scanner; public class Vault implements VaultInterface { + public boolean config; InputStream inputS = System.in; OutputStream outputS = System.out; @@ -19,7 +20,8 @@ public class Vault implements VaultInterface { public void configure(){ StringBuilder sbcm = new StringBuilder(); - //Scanner scan = new Scanner(inputS); + Scanner scan = new Scanner(inputS); + config = true; sbcm.append("Configure:\n"); sbcm.append("- Passwordlength: l\n"); @@ -28,6 +30,13 @@ public class Vault implements VaultInterface { println(sbcm.toString()); + String input = scan.nextLine(); + + if (input.equals("e")) { + config = false; + + } + } public void addCredential(){ diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 80e003b..f506dcc 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -48,6 +48,14 @@ public class VaultTest { assertTrue(outputStream.toString().startsWith("Configure:")); } + @Test + void exitConfigurationMenu(){ + vlt.inputS = new ByteArrayInputStream("e".getBytes(StandardCharsets.UTF_8)); + vlt.configure(); + assertFalse(vlt.config); + } + + private ByteArrayInputStream getEmptyStringInputStream() { return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));