Added functions & test cases: deleteAccount and getAllAccounts
This commit is contained in:
@@ -429,4 +429,67 @@ public class PrivateBankTest {
|
||||
AccountAlreadyExistsException.class, () -> privateBank.readAccounts()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@DisplayName("Delete existing account")
|
||||
@Order(20)
|
||||
@Test
|
||||
public void testDeleteExistingAccount() {
|
||||
assertDoesNotThrow(
|
||||
() -> privateBank.createAccount(
|
||||
"Konto_X",
|
||||
List.of(
|
||||
new OutgoingTransfer(
|
||||
"01.01.2000",
|
||||
100,
|
||||
"OutgoingTransfer to Hans",
|
||||
"Konto_X",
|
||||
"Hans"
|
||||
),
|
||||
new IncomingTransfer(
|
||||
"01.01.2000",
|
||||
100,
|
||||
"IncomingTransfer from Hans",
|
||||
"Hans",
|
||||
"Konto_X"
|
||||
),
|
||||
new IncomingTransfer(
|
||||
"01.01.2000",
|
||||
300,
|
||||
"IncomingTransfer from Tom",
|
||||
"Tom",
|
||||
"Konto_X"
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
assertDoesNotThrow(
|
||||
() -> privateBank.writeAccount("Konto_X")
|
||||
);
|
||||
|
||||
assertTrue(
|
||||
() -> privateBank.containsAccount("Konto_X")
|
||||
);
|
||||
|
||||
assertDoesNotThrow(
|
||||
() -> privateBank.deleteAccount("Konto_X")
|
||||
);
|
||||
|
||||
assertFalse(
|
||||
() -> privateBank.containsAccount("Konto_X")
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@DisplayName("Delete non existing account")
|
||||
@Order(21)
|
||||
@Test
|
||||
public void testDeleteNonExistingAccount() {
|
||||
assertThrows(
|
||||
AccountDoesNotExistException.class, () -> privateBank.deleteAccount("Konto_X")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user