Browse Source

control menu with custom InputStream

feature-implement-menu-control
binsky 3 years ago
parent
commit
1189102c07
  1. 11
      src/main/java/PasswordManager.java
  2. 4
      src/main/java/PasswordManagerInterface.java
  3. 6
      src/test/java/PasswordManagerTest.java

11
src/main/java/PasswordManager.java

@ -1,7 +1,14 @@
import java.io.BufferedInputStream;
import java.io.InputStream;
public class PasswordManager implements PasswordManagerInterface {
public static void main(String[] args) {
PasswordManager pm = new PasswordManager();
pm.showMenu();
while (true) {
InputStream inputStream = System.in;
pm.showMenu(inputStream);
}
}
public PasswordManager() {
@ -19,7 +26,7 @@ public class PasswordManager implements PasswordManagerInterface {
}
@Override
public void showMenu() {
public void showMenu(InputStream inputStream) {
}
}

4
src/main/java/PasswordManagerInterface.java

@ -1,7 +1,9 @@
import java.io.InputStream;
public interface PasswordManagerInterface {
public static void main(String[] args) {
};
public void listVaults();
public void openVault();
public void showMenu();
public void showMenu(InputStream inputStream);
}

6
src/test/java/PasswordManagerTest.java

@ -1,6 +1,10 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.*;
@ -30,6 +34,6 @@ class PasswordManagerTest {
@Test
void showMenu() {
pm.showMenu();
pm.showMenu(new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8)));
}
}
Loading…
Cancel
Save