Browse Source

added Configuration Menu

feature-vault
fdai6352 3 years ago
parent
commit
091c425ae1
  1. 26
      src/main/java/Vault.java
  2. 29
      src/test/java/VaultTest.java

26
src/main/java/Vault.java

@ -1,6 +1,32 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
public class Vault implements VaultInterface { public class Vault implements VaultInterface {
InputStream inputS = System.in;
OutputStream outputS = System.out;
private void println(String output) {
try {
outputS.write((output + "\n").getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
}
public void configure(){ public void configure(){
StringBuilder sbcm = new StringBuilder();
//Scanner scan = new Scanner(inputS);
sbcm.append("Configure:\n");
sbcm.append("- Passwordlength: l\n");
sbcm.append("- Have Capitals: h\n");
sbcm.append("- exit: e\n");
println(sbcm.toString());
} }

29
src/test/java/VaultTest.java

@ -7,20 +7,22 @@ import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import static org.junit.jupiter.api.Assertions.*;
public class VaultTest { public class VaultTest {
static Vault vlt;
Vault vlt = new Vault();
@BeforeAll
/* @BeforeAll
static void init() { static void init() {
vlt = new Vault(); vlt = new Vault();
}
}*/
/* @BeforeEach
@BeforeEach
void reset() { void reset() {
pm.outputStream = System.out;
pm.inputStream = System.in;
}*/
vlt.outputS = System.out;
vlt.inputS = System.in;
}
@Test @Test
void configure() {vlt.configure();} void configure() {vlt.configure();}
@ -37,4 +39,17 @@ public class VaultTest {
@Test @Test
void loadFromJson() {vlt.loadFromJson();} void loadFromJson() {vlt.loadFromJson();}
@Test
void openConfigureMenu() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = getEmptyStringInputStream();
vlt.outputS = outputStream;
vlt.configure();
assertTrue(outputStream.toString().startsWith("Configure:"));
}
private ByteArrayInputStream getEmptyStringInputStream() {
return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
}
} }
Loading…
Cancel
Save