From 278f120b0477e67e542a0d0c1723718ef0c27b32 Mon Sep 17 00:00:00 2001 From: binsky Date: Mon, 14 Feb 2022 20:49:53 +0100 Subject: [PATCH] implement creating a new vault --- src/main/java/PasswordManager.java | 15 ++++++++++----- src/test/java/PasswordManagerTest.java | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/PasswordManager.java b/src/main/java/PasswordManager.java index 29960fd..10cf125 100644 --- a/src/main/java/PasswordManager.java +++ b/src/main/java/PasswordManager.java @@ -12,6 +12,7 @@ public class PasswordManager implements PasswordManagerInterface { boolean running = true; InputStream inputStream = System.in; OutputStream outputStream = System.out; + ArrayList vaults = new ArrayList<>(); public static void main(String[] args) { PasswordManager pm = new PasswordManager(); @@ -26,11 +27,6 @@ public class PasswordManager implements PasswordManagerInterface { println("Hello World"); } - @Override - public void listVaults() { - println("Vaults:"); - } - private void println(String output) { try { outputStream.write((output + "\n").getBytes(StandardCharsets.UTF_8)); @@ -39,6 +35,15 @@ public class PasswordManager implements PasswordManagerInterface { } } + @Override + public void listVaults() { + println("Vaults:"); + } + + public void createNewVault() { + vaults.add(new Vault()); + } + @Override public void openVault() { diff --git a/src/test/java/PasswordManagerTest.java b/src/test/java/PasswordManagerTest.java index c96f747..c4d3fb6 100644 --- a/src/test/java/PasswordManagerTest.java +++ b/src/test/java/PasswordManagerTest.java @@ -88,6 +88,13 @@ class PasswordManagerTest { assertTrue(outputStream.toString().startsWith("\nciip Gruppe 8")); } + @Test + void createNewVault() { + assertEquals(0, pm.vaults.size()); + pm.createNewVault(); + assertEquals(1, pm.vaults.size()); + } + private ByteArrayInputStream getEmptyStringInputStream() { return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8)); }