Skip to content

Commit

Permalink
valentinajemuovic#72 Third Party Integration - National Identity Prov…
Browse files Browse the repository at this point in the history
…ider - Updated test should_open_account_given_valid_request
  • Loading branch information
valentinajemuovic committed Jan 4, 2023
1 parent 88469f5 commit 5c0faf9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 25 deletions.
20 changes: 7 additions & 13 deletions adapter-thirdparty-fake/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
plugins {
id 'java'
}

group 'com.optivem.kata.banking'
version '0.0.1-SNAPSHOT'
dependencies {
implementation project(':core')

repositories {
mavenCentral()
testImplementation project(':adapter-base')
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
bootJar {
enabled = false
}

test {
useJUnitPlatform()
jar {
enabled = true
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.optivem.kata.banking.adapters.driven.fake;

public class FakeNationalIdentityProvider {
public void add(String nationalIdentityNumber) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.optivem.kata.banking.adapters.driven.fake.givens;

import com.optivem.kata.banking.adapters.driven.fake.FakeNationalIdentityProvider;

public class FakeNationalIdentityProviderGiven {
private final FakeNationalIdentityProvider provider;

public FakeNationalIdentityProviderGiven(FakeNationalIdentityProvider provider) {
this.provider = provider;
}

public void contains(String nationalIdentityNumber) {
provider.add(nationalIdentityNumber);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.optivem.kata.banking.adapters.driven.fake.givens;

import com.optivem.kata.banking.adapters.driven.fake.FakeNationalIdentityProvider;

import java.util.Collection;

public class FakeNationalIdentityProviderGivens {
public static FakeNationalIdentityProviderGiven givenThat(FakeNationalIdentityProvider provider) {
return new FakeNationalIdentityProviderGiven(provider);
}
}
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependencies {
testImplementation project(':adapter-generation-fake')
testImplementation project(':adapter-messaging-fake')
testImplementation project(':adapter-persistence-fake')
testImplementation project(':adapter-thirdparty-fake')
testImplementation project(':adapter-time-fake')
testImplementation project(':test-facade')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.optivem.kata.banking.adapters.driven.fake.*;
import com.optivem.kata.banking.adapters.driven.fake.givens.FakeGenerationGivens;
import com.optivem.kata.banking.adapters.driven.fake.givens.FakeTimeGivens;
import com.optivem.kata.banking.adapters.driven.fake.givens.FakeNationalIdentityProviderGivens;
import com.optivem.kata.banking.adapters.driven.fake.verifies.BankAccountStorageVerifies;
import com.optivem.kata.banking.adapters.driven.fake.verifies.FakeEventBusVerifies;
import com.optivem.kata.banking.core.common.factories.CrudUseCaseFactory;
Expand All @@ -23,14 +24,14 @@
import java.time.LocalTime;
import java.util.stream.Stream;

import static com.optivem.kata.banking.core.common.Givens.givenThat;
import static com.optivem.kata.banking.core.common.Verifications.verifyThat;
import static com.optivem.kata.banking.core.common.builders.requests.OpenAccountRequestBuilder.openAccountRequest;
import static com.optivem.kata.banking.core.common.data.MethodSources.NEGATIVE_INTEGERS;
import static com.optivem.kata.banking.core.common.data.MethodSources.NULL_EMPTY_WHITESPACE;
import static org.assertj.core.api.Assertions.assertThat;

class OpenAccountUseCaseTest {
private FakeNationalIdentityProvider nationalIdentityProvider;
private FakeBankAccountStorage storage;
private FakeAccountIdGenerator accountIdGenerator;
private FakeAccountNumberGenerator accountNumberGenerator;
Expand All @@ -40,12 +41,13 @@ class OpenAccountUseCaseTest {
private Command.Handler<OpenAccountRequest, OpenAccountResponse> useCase;

private static Stream<Arguments> should_open_account_given_valid_request() {
return Stream.of(Arguments.of("John", "Smith", 0, 3456, "GB41OMQP68570038161775", LocalDate.of(2022, 5, 20)),
Arguments.of("Mary", "McDonald", 50, 735353, "GB36BMFK75394735916876", LocalDate.of(2021, 6, 15)));
return Stream.of(Arguments.of("ABC", "John", "Smith", 0, 3456, "GB41OMQP68570038161775", LocalDate.of(2022, 5, 20)),
Arguments.of("DEF", "Mary", "McDonald", 50, 735353, "GB36BMFK75394735916876", LocalDate.of(2021, 6, 15)));
}

@BeforeEach
void init() {
this.nationalIdentityProvider = new FakeNationalIdentityProvider();
this.storage = new FakeBankAccountStorage();
this.accountIdGenerator = new FakeAccountIdGenerator();
this.accountNumberGenerator = new FakeAccountNumberGenerator();
Expand All @@ -60,7 +62,8 @@ void init() {

@ParameterizedTest
@MethodSource
void should_open_account_given_valid_request(String firstName, String lastName, int initialBalance, long generatedAccountId, String generatedAccountNumber, LocalDate openingDate) {
void should_open_account_given_valid_request(String nationalIdentityNumber, String firstName, String lastName, int initialBalance, long generatedAccountId, String generatedAccountNumber, LocalDate openingDate) {
FakeNationalIdentityProviderGivens.givenThat(nationalIdentityProvider).contains(nationalIdentityNumber);
FakeGenerationGivens.givenThat(accountIdGenerator).willGenerate(generatedAccountId);
FakeGenerationGivens.givenThat(accountNumberGenerator).willGenerate(generatedAccountNumber);
FakeTimeGivens.givenThat(dateTimeService).willReturn(LocalDateTime.of(openingDate, LocalTime.MIN));
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ include 'adapter-messaging-inmemory'
include 'adapter-persistence-fake'
include 'adapter-persistence-jpa'
include 'adapter-persistence-mongo'
include 'adapter-thirdparty-fake'
include 'adapter-time-fake'
include 'adapter-time-system'

include 'adapter-restapi-spring'
include 'adapter-thirdparty-fake'


0 comments on commit 5c0faf9

Please sign in to comment.