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

Create DiffblueCover.yml #126

Closed
wants to merge 2 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
62 changes: 62 additions & 0 deletions .github/workflows/DiffblueCover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Example Workflow

# Diffblue Cover CI responds to pull request
on:
pull_request:

# Avoid running the same workflow on the same branch concurrently
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

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

# Checkout the repository with permission to push
- name: Checkout
uses: actions/checkout@v4
with:
# The default GITHUB_TOKEN doesn't have the necessary permissions
# so a custom token should be used here with sufficient access.
#
# Must have access to the project with at least Write role, and scopes
# including code, commit-statuses, pull-requests, workflows and actions.
#
token: ${{ secrets.DIFFBLUE_ACCESS_TOKEN }}

# Run Diffblue Cover
- name: Diffblue Cover
uses: diffblue/cover-github-action@tigers/TG-21006-release-testing
env:
JVM_ARGS: -Xmx4096m
GITHUB_PR_NUMBER: ${{ github.event.number }}
with:
# The access token used to push commits and call GitHub APIs.
#
# Must have access to the project with at least Write role, and scopes
# including code, commit-statuses, pull-requests, workflows and actions.
access-token: ${{ secrets.DIFFBLUE_ACCESS_TOKEN }}

# The license key provided in your welcome email or provided by your organization.
# Alternatively obtain a free trial key from https://www.diffblue.com/try-cover/github.
license-key: ${{ secrets.DIFFBLUE_LICENSE_KEY }}

# Working directory where the project can be found, if not at the root.
# working-directory: path/to/project

# The Diffblue Cover commands and options to use.
# args: >-
# ci
# activate
# build
# validate
# create

# Collect Diffblue Cover log files
- name: Diffblue Artifacts
uses: actions/upload-artifact@v4
with:
name: logs
path: |
**/.diffblue/**
89 changes: 89 additions & 0 deletions src/test/java/io/diffblue/corebanking/CoreBankingDiffblueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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#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