Browse Source

implement menu navigation to create a new vault

feature-create-new-vault
binsky 3 years ago
parent
commit
f8ab3d1a06
  1. 7
      src/main/java/PasswordManager.java
  2. 10
      src/test/java/PasswordManagerTest.java

7
src/main/java/PasswordManager.java

@ -58,7 +58,8 @@ public class PasswordManager implements PasswordManagerInterface {
sb.append("\nciip Gruppe 8 - Password Manager\n\n");
sb.append("Menu:\n");
sb.append("- list vaults: l:\n");
sb.append("- list vaults: l\n");
sb.append("- create new vault: v\n");
sb.append("- select vault: v x (replace x with vault id)\n");
sb.append("- exit: e\n");
@ -70,7 +71,9 @@ public class PasswordManager implements PasswordManagerInterface {
running = false;
} else if (input.equals("l")) {
listVaults();
} else if (input.startsWith("v")) {
} else if (input.equals("v")) {
createNewVault();
} else if (input.startsWith("v")) {
String vaultAction = (input.replace('v', ' ')).trim();
int vaultId = -1;

10
src/test/java/PasswordManagerTest.java

@ -49,6 +49,16 @@ class PasswordManagerTest {
assertTrue(outputStream.toString().endsWith("Vaults:\n"));
}
@Test
void menuNavigationCreateNewVault() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
pm.inputStream = new ByteArrayInputStream("v\n".getBytes(StandardCharsets.UTF_8));
pm.outputStream = outputStream;
int vaultCount = pm.vaults.size();
pm.showMenu();
assertEquals(vaultCount + 1, pm.vaults.size());
}
@Test
void menuNavigationOpenVault() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

Loading…
Cancel
Save