Skip to content

Commit

Permalink
Fix account details model (#21)
Browse files Browse the repository at this point in the history
* Change Singleton to Transient

* Update account details model
Change to WhenAll for fetching account details

* Remove uneccessary properties from bank models
Add log text that explains which field went wrong when serializing

* Refactor and enhance banking service and tests

- Update `BankClient_v2.cs` to adjust JSON properties and make `CreditDebitIndicator` nullable.
- Add `AccountExtensions.cs` with error logging method.
- Add `HasErrors` property to `AccountV2` in `BankResponse.cs`.
- Enhance `GetAccountDetailsV2` in `BankService.cs` for better error handling and logging.
- Update `Altinn.Dan.Plugin.Banking.Test.csproj` to target `net8.0`, add `FakeItEasy`, and reference `Altinn.Dan.Plugin.Banking`.
- Add `FakeableHttpMessageHandler.cs` for handling HTTP requests in tests and generating certificates.
- Add `BankServiceTests.cs` with comprehensive unit tests for `BankService`.
- Remove obsolete `UnitTest1.cs`.

* Fix failed tests

* Nullable enabled
Remove all required and add back some
Remove roles
Remove unused extension
Remove unused usings
Add tests

* Fix property references a bit after introducing nullable enable

* Fix balances

* Fix parallel request issues in GetAccounts method

Modified GetAccounts in BankService to fetch account details sequentially instead of in parallel to avoid 200 OK Internal Server Errors from Nordea. Added try-catch block to handle ApiException for each account individually, logging and adding default values for accounts with errors. Non-API exceptions are rethrown. Added comments explaining changes.

* Fix failing test
  • Loading branch information
DanRJ authored Feb 18, 2025
1 parent 3f9ee8b commit 4b638fb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public async Task GetAccounts_GetAccountDetailsInternalServerError_AccountHasErr
Assert.IsNotNull(result);
Assert.AreEqual(1, result.BankAccounts.Count);
Assert.IsFalse(result.BankAccounts.Single().HasErrors);
Assert.AreEqual(2, result.BankAccounts.Single().Accounts.Count);
Assert.AreEqual(3, result.BankAccounts.Single().Accounts.Count);
Assert.IsTrue(result.BankAccounts.Single().Accounts.Any(x => x.HasErrors));
}

Expand Down

0 comments on commit 4b638fb

Please sign in to comment.