Browse Source

implement creating a new vault

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

15
src/main/java/PasswordManager.java

@ -12,6 +12,7 @@ public class PasswordManager implements PasswordManagerInterface {
boolean running = true; boolean running = true;
InputStream inputStream = System.in; InputStream inputStream = System.in;
OutputStream outputStream = System.out; OutputStream outputStream = System.out;
ArrayList<Vault> vaults = new ArrayList<>();
public static void main(String[] args) { public static void main(String[] args) {
PasswordManager pm = new PasswordManager(); PasswordManager pm = new PasswordManager();
@ -26,11 +27,6 @@ public class PasswordManager implements PasswordManagerInterface {
println("Hello World"); println("Hello World");
} }
@Override
public void listVaults() {
println("Vaults:");
}
private void println(String output) { private void println(String output) {
try { try {
outputStream.write((output + "\n").getBytes(StandardCharsets.UTF_8)); 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 @Override
public void openVault() { public void openVault() {

7
src/test/java/PasswordManagerTest.java

@ -88,6 +88,13 @@ class PasswordManagerTest {
assertTrue(outputStream.toString().startsWith("\nciip Gruppe 8")); 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() { private ByteArrayInputStream getEmptyStringInputStream() {
return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8)); return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
} }

Loading…
Cancel
Save