Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinajemuovic committed Jan 17, 2024
1 parent 40ee1da commit f3a8b2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.optivem.kata.banking.core.internal.cleanarch.usecases;
package com.optivem.kata.banking.core.internal.cleanarch.domain.accounts;

import com.optivem.kata.banking.core.ports.driver.exceptions.ValidationException;
import com.optivem.kata.banking.core.ports.driver.exceptions.ValidationMessages;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
Expand All @@ -15,13 +17,17 @@ private NationalIdentityNumber(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static NationalIdentityNumber of(String value) {
return new NationalIdentityNumber(value);
}

private void checkValueNotNull(String value) {
if (value == null || value.isEmpty()) {
throw new IllegalArgumentException("National identity number cannot be null or empty");
throw new ValidationException(ValidationMessages.NATIONAL_IDENTITY_NUMBER_EMPTY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.optivem.kata.banking.core.internal.cleanarch.usecases;

import an.awesome.pipelinr.Command;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.AccountHolderName;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.Balance;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.BankAccount;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.BankAccountRepository;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.AccountOpened;
import com.optivem.kata.banking.core.internal.cleanarch.domain.accounts.*;
import com.optivem.kata.banking.core.internal.cleanarch.domain.common.events.EventPublisher;
import com.optivem.kata.banking.core.ports.driven.CustomerGateway;
import com.optivem.kata.banking.core.ports.driven.DateTimeService;
Expand Down Expand Up @@ -43,15 +39,17 @@ public OpenAccountResponse handle(OpenAccountRequest request) {

var timestamp = dateTimeService.now();

var isBlacklisted = customerGateway.isBlacklisted(String.valueOf(nationalIdentityNumber));
var nationalIdentityNumberValue = nationalIdentityNumber.getValue(); // TODO: VC: Make additional interface in ACL, sot aht we can directly pass the VO

var isBlacklisted = customerGateway.isBlacklisted(nationalIdentityNumberValue);

if(isBlacklisted) {
throw new ValidationException(ValidationMessages.NATIONAL_IDENTITY_NUMBER_BLACKLISTED);
}

var bankAccount = createBankAccount(String.valueOf(nationalIdentityNumber), accountHolderName, balance, timestamp);
var bankAccount = createBankAccount(nationalIdentityNumberValue, accountHolderName, balance, timestamp);

var exists = nationalIdentityGateway.exists(String.valueOf(nationalIdentityNumber));
var exists = nationalIdentityGateway.exists(nationalIdentityNumberValue);
if(!exists) {
throw new ValidationException(ValidationMessages.NATIONAL_IDENTITY_NUMBER_NONEXISTENT);
}
Expand Down

0 comments on commit f3a8b2b

Please sign in to comment.