-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diffblue Cover created unit tests for module io.diffblue.corebanking:…
…CoreBanking
- Loading branch information
1 parent
590fa21
commit 2f01136
Showing
17 changed files
with
1,508 additions
and
0 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
src/test/java/io/diffblue/corebanking/CoreBankingDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package io.diffblue.corebanking; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import io.diffblue.corebanking.account.Account; | ||
import io.diffblue.corebanking.client.Client; | ||
import io.diffblue.corebanking.datamanagement.ReadFromDB; | ||
import io.diffblue.corebanking.transaction.TransactionException; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CoreBankingDiffblueTest { | ||
/** | ||
* Method under test: {@link CoreBanking#purgeCoreBanking()} | ||
*/ | ||
@Test | ||
void testPurgeCoreBanking() throws TransactionException { | ||
// Arrange | ||
CoreBanking readFromDBResult = ReadFromDB.readFromDB(); | ||
|
||
// Act | ||
readFromDBResult.purgeCoreBanking(); | ||
|
||
// Assert | ||
assertTrue(readFromDBResult.getAccounts().isEmpty()); | ||
assertTrue(readFromDBResult.getClients().isEmpty()); | ||
} | ||
|
||
/** | ||
* Methods under test: | ||
* | ||
* <ul> | ||
* <li>default or parameterless constructor of {@link CoreBanking} | ||
* <li>{@link CoreBanking#getAccounts()} | ||
* <li>{@link CoreBanking#getClients()} | ||
* </ul> | ||
*/ | ||
@Test | ||
void testGettersAndSetters() { | ||
// Arrange and Act | ||
CoreBanking actualCoreBanking = new CoreBanking(); | ||
List<Account> actualAccounts = actualCoreBanking.getAccounts(); | ||
List<Client> actualClients = actualCoreBanking.getClients(); | ||
|
||
// Assert | ||
assertTrue(actualAccounts.isEmpty()); | ||
assertTrue(actualClients.isEmpty()); | ||
} | ||
|
||
/** | ||
* Method under test: {@link CoreBanking#openNewAccount(Client, long)} | ||
*/ | ||
@Test | ||
void testOpenNewAccount() throws TransactionException { | ||
// Arrange | ||
CoreBanking readFromDBResult = ReadFromDB.readFromDB(); | ||
|
||
// Act | ||
Account actualOpenNewAccountResult = readFromDBResult.openNewAccount(new Client("Dr Jane Doe"), 10L); | ||
|
||
// Assert | ||
assertEquals("Current", actualOpenNewAccountResult.getAccountName()); | ||
Client client = actualOpenNewAccountResult.getClient(); | ||
assertEquals("Dr Jane Doe", client.getClientName()); | ||
assertEquals(1, client.getAccounts().size()); | ||
assertEquals(10L, actualOpenNewAccountResult.getCurrentBalance()); | ||
assertEquals(7, readFromDBResult.getAccounts().size()); | ||
assertEquals(Account.AccountState.OPEN, actualOpenNewAccountResult.getAccountState()); | ||
assertTrue(actualOpenNewAccountResult.getAccountStatement().getTransactions().isEmpty()); | ||
} | ||
|
||
/** | ||
* Method under test: {@link CoreBanking#openNewAccount(Client, long)} | ||
*/ | ||
@Test | ||
void testOpenNewAccount2() throws TransactionException { | ||
// Arrange | ||
CoreBanking readFromDBResult = ReadFromDB.readFromDB(); | ||
|
||
// Act | ||
Account actualOpenNewAccountResult = readFromDBResult.openNewAccount(new Client("Client Name"), 4976L); | ||
|
||
// Assert | ||
Client client = actualOpenNewAccountResult.getClient(); | ||
assertEquals("Client Name", client.getClientName()); | ||
assertEquals("Current", actualOpenNewAccountResult.getAccountName()); | ||
assertEquals(1, client.getAccounts().size()); | ||
assertEquals(4976L, actualOpenNewAccountResult.getCurrentBalance()); | ||
assertEquals(7, readFromDBResult.getAccounts().size()); | ||
assertEquals(Account.AccountState.OPEN, actualOpenNewAccountResult.getAccountState()); | ||
assertTrue(actualOpenNewAccountResult.getAccountStatement().getTransactions().isEmpty()); | ||
} | ||
|
||
/** | ||
* Method under test: {@link CoreBanking#registerNewClient(Client)} | ||
*/ | ||
@Test | ||
void testRegisterNewClient() throws TransactionException { | ||
// Arrange | ||
CoreBanking readFromDBResult = ReadFromDB.readFromDB(); | ||
Client client = new Client("Dr Jane Doe"); | ||
|
||
// Act | ||
Client actualRegisterNewClientResult = readFromDBResult.registerNewClient(client); | ||
|
||
// Assert | ||
assertEquals(4, readFromDBResult.getClients().size()); | ||
assertSame(client, actualRegisterNewClientResult); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/io/diffblue/corebanking/CoreBankingExceptionDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.diffblue.corebanking; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CoreBankingExceptionDiffblueTest { | ||
/** | ||
* Method under test: {@link CoreBankingException#CoreBankingException(String)} | ||
*/ | ||
@Test | ||
void testNewCoreBankingException() { | ||
// Arrange and Act | ||
CoreBankingException actualCoreBankingException = new CoreBankingException("An error occurred"); | ||
|
||
// Assert | ||
assertEquals("An error occurred", actualCoreBankingException.getLocalizedMessage()); | ||
assertEquals("An error occurred", actualCoreBankingException.getMessage()); | ||
assertNull(actualCoreBankingException.getCause()); | ||
assertEquals(0, actualCoreBankingException.getSuppressed().length); | ||
} | ||
} |
Oops, something went wrong.