Skip to content

Commit

Permalink
Diffblue Cover created unit tests for module io.diffblue.corebanking:…
Browse files Browse the repository at this point in the history
…CoreBanking
  • Loading branch information
db-ci-pipeline committed Mar 21, 2024
1 parent 590fa21 commit 2f01136
Show file tree
Hide file tree
Showing 17 changed files with 1,508 additions and 0 deletions.
111 changes: 111 additions & 0 deletions src/test/java/io/diffblue/corebanking/CoreBankingDiffblueTest.java
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);
}
}
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);
}
}
Loading

0 comments on commit 2f01136

Please sign in to comment.