From c2952ab42cba02b47ff7413a6e18b124a62d65b4 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:38:32 +0100 Subject: [PATCH] setPWLength refactor --- src/main/java/Vault.java | 9 +++------ src/test/java/VaultTest.java | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index e80e2f5..f62f188 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -40,8 +40,9 @@ public class Vault implements VaultInterface { if (input.equals("e")) { config = false; }else if (input.equals("l")) { - String inputpw = scan.nextLine(); - setPWLength(inputpw); + println("Set PW length:"); + String inputPw = scan.nextLine(); + setPWLength(inputPw); }else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { println("Please enter valid key."); } @@ -49,16 +50,12 @@ public class Vault implements VaultInterface { } public void setPWLength(String pwLength){ - println("Set PW length:"); - try { PWLength = Integer.parseInt(pwLength); } catch (NumberFormatException e) { println("Please Enter Valid Number."); } - - println("\nNew PWlength is now: "); } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index f13a60b..3d4e97e 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -96,6 +96,7 @@ public class VaultTest { vlt.outputS = outputStream; vlt.configure(); assertEquals(7, vlt.PWLength); + assertTrue(outputStream.toString().contains("Set")); } @Test