Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Diffblue Cover #122

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/DiffblueCover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Diffblue Cover

on:
pull_request:

jobs:
Diffblue:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3
with:
# The default GITHUB_TOKEN doesn't have the necessary permissions
# so a custom token should be used here with sufficient access.
token: ${{ secrets.DIFFBLUE_TOKEN }}

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'zulu'

- name: Maven Install
run: mvn --batch-mode install

- name: Diffblue Cover
uses: diffblue/cover-github-action@main
env:
GITHUB_TOKEN: ${{ secrets.DIFFBLUE_TOKEN }}
JVM_ARGS: -Xmx4096m
with:
# License key used to activate the installation
license-key: ${{ secrets.DIFFBLUE_LICENSE_KEY }}
# User name and email used to author commits
user-name: Diffblue CI
user-email: [email protected]
# Add a differentiator based on the matrix
topic-id-differentiator: ${{ matrix.os }}
88 changes: 88 additions & 0 deletions src/test/java/io/diffblue/corebanking/CoreBankingDiffblueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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 {
/**
* Methods under test:
*
* <ul>
* <li>default or parameterless constructor of {@link CoreBanking}
* <li>{@link CoreBanking#getAccounts()}
* <li>{@link CoreBanking#getClients()}
* </ul>
*/
@Test
void testConstructor() {
// 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#purgeCoreBanking()}
*/
@Test
void testPurgeCoreBanking() throws TransactionException {
// Arrange
CoreBanking readFromDBResult = ReadFromDB.readFromDB();

// Act
readFromDBResult.purgeCoreBanking();

// Assert
assertTrue(readFromDBResult.getAccounts().isEmpty());
assertTrue(readFromDBResult.getClients().isEmpty());
}

/**
* Method under test: {@link CoreBanking#openNewAccount(Client, long)}
*/
@Test
void testOpenNewAccount() throws TransactionException {
// Arrange
CoreBanking readFromDBResult = ReadFromDB.readFromDB();
Client client = new Client("Dr Jane Doe");

// Act
Account actualOpenNewAccountResult = readFromDBResult.openNewAccount(client, 10L);

// Assert
assertEquals("Current", actualOpenNewAccountResult.getAccountName());
assertEquals(10L, actualOpenNewAccountResult.getCurrentBalance());
Client client2 = actualOpenNewAccountResult.getClient();
assertSame(client, client2);
assertEquals(Account.AccountState.OPEN, actualOpenNewAccountResult.getAccountState());
assertEquals(1, client2.getAccounts().size());
assertTrue(actualOpenNewAccountResult.getAccountStatement().getTransactions().isEmpty());
assertEquals(7, readFromDBResult.getAccounts().size());
}

/**
* 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 and Assert
assertSame(client, readFromDBResult.registerNewClient(client));
assertEquals(4, readFromDBResult.getClients().size());
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 testConstructor() {
// Arrange and Act
CoreBankingException actualCoreBankingException = new CoreBankingException("An error occurred");

// Assert
assertNull(actualCoreBankingException.getCause());
assertEquals(0, actualCoreBankingException.getSuppressed().length);
assertEquals("An error occurred", actualCoreBankingException.getMessage());
assertEquals("An error occurred", actualCoreBankingException.getLocalizedMessage());
}
}

Loading