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

NEW FEATURE #29

Merged
merged 35 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7fa3bd7
Update dependencies version
Oct 17, 2022
f3a1385
Exclude junit dependency
Oct 17, 2022
6484450
fix import statements on new util-classes directory
Oct 17, 2022
884a444
Added setters for Client fields
Oct 17, 2022
5ecdf60
made Consumer<DataSource> setDataSource() as a default method.
Oct 17, 2022
4bc223f
removed accidental 's' letter on getAllLoans() comment
Oct 17, 2022
2a7d6b0
Add custom exception for non-found clients
Oct 17, 2022
44be8a0
Renamed AtmDAOImplementation class to InDatabase
Oct 17, 2022
3e0ca02
Renamed AtmDAOImplementation to InDatabase
Oct 17, 2022
2b92ec9
Added comments in mutator methods
Oct 17, 2022
0462d00
changed Function<String, Map<String, List<Message>>> getMessage() met…
Oct 17, 2022
74adde6
Add InMemory Database
Oct 17, 2022
528dffd
Removed Function<String, Map<String, List<Message>>> getMessage() fun…
Oct 17, 2022
88f7a87
Added mutator functions for Loan fields.
Oct 17, 2022
ba15c80
Added approve(), decline(), and removeLoan() method implementations
Oct 17, 2022
f20e9ac
Added afterAll() method
Oct 17, 2022
436cd8d
Added empty test for InMemory Database
Oct 17, 2022
5319640
moved from database folder to dao folder
Oct 17, 2022
f03a07b
moved to same folder dao
Oct 17, 2022
30b9bc7
renamed class from InDatabaseAtmServiceTest to InDatabaseTest
Oct 17, 2022
bc7460e
Util class that is used for testing
Oct 17, 2022
9a8a99b
renamed Person import to Util
Oct 17, 2022
907507a
renamed class from InMemoryAtmServiceTest to InMemoryTest
Oct 17, 2022
31ce31e
removed
Oct 17, 2022
e2a6558
added postgresql dependency and excluded
Oct 17, 2022
fbec9cb
added custom class LoanDoesNotExist
Oct 17, 2022
ebb6b0d
removed AtmDao import
Oct 17, 2022
ab3a7e5
refactor else thrown exception
Oct 17, 2022
026aa83
refactor Function<Loan, Status> requestLoan() method body
Oct 17, 2022
a9130eb
replaced repeated tests with normal test [FAILING TESTS]
Oct 17, 2022
21171b6
renamed db field to jdbcTemplate and added datasource check
Oct 17, 2022
c2be50a
re-ordered imports abd changed thrown exception in getClientByAccount…
Oct 18, 2022
379c2ab
refactored test **TEST PASSED**
Oct 18, 2022
537f60b
added comments
Oct 18, 2022
6dc7d74
refactored **TEST PASSED**
Oct 18, 2022
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ ________________________________________

```java
import io.github.pitzzahh.atm.database.DatabaseConnection;
import io.github.pitzzahh.atm.dao.AtmDAOImplementation;
import io.github.pitzzahh.atm.dao.InDatabase;
import io.github.pitzzahh.atm.service.AtmService;
import io.github.pitzzahh.atm.dao.AtmDAO;

public class App {
private static final AtmDAO ATM_DAO = new AtmDAOImplementation();
private static final AtmDAO ATM_DAO = new InDatabase();
private static final DatabaseConnection DATABASE_CONNECTION = new DatabaseConnection();

public static void main(String[] args) {
Expand All @@ -39,17 +39,20 @@ public class App {
```java
import com.github.pitzzahh.utilities.classes.enums.Gender;
import io.github.pitzzahh.atm.database.DatabaseConnection;

import static com.github.pitzzahh.utilities.Print.println;
import io.github.pitzzahh.atm.dao.AtmDAOImplementation;

import io.github.pitzzahh.atm.dao.InDatabase;
import com.github.pitzzahh.utilities.classes.Person;
import io.github.pitzzahh.atm.service.AtmService;
import io.github.pitzzahh.atm.entity.Client;
import io.github.pitzzahh.atm.dao.AtmDAO;

import java.time.LocalDate;
import java.time.Month;

public class App {
private static final AtmDAO ATM_DAO = new AtmDAOImplementation();
private static final AtmDAO ATM_DAO = new InDatabase();
private static final DatabaseConnection DATABASE_CONNECTION = new DatabaseConnection();

public static void main(String[] args) {
Expand Down
2 changes: 1 addition & 1 deletion docs/io/github/pitzzahh/atm/dao/AtmDAOImplementation.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<h1 title="Class AtmDAOImplementation" class="title">Class AtmDAOImplementation</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">io.github.pitzzahh.atm.dao.AtmDAOImplementation</div>
<div class="inheritance">io.github.pitzzahh.atm.dao.InDatabase</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<!-- Generated by javadoc (17) on Fri Aug 12 09:05:49 PST 2022 -->
<title>Uses of Class io.github.pitzzahh.atm.dao.AtmDAOImplementation (automated-teller-machine-console 1.0.2 API)</title>
<title>Uses of Class io.github.pitzzahh.atm.dao.InDatabase (automated-teller-machine-console 1.0.2 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2022-08-12">
Expand Down Expand Up @@ -49,9 +49,9 @@
<div class="flex-content">
<main role="main">
<div class="header">
<h1 title="Uses of Class io.github.pitzzahh.atm.dao.AtmDAOImplementation" class="title">Uses of Class<br>io.github.pitzzahh.atm.dao.AtmDAOImplementation</h1>
<h1 title="Uses of Class io.github.pitzzahh.atm.dao.InDatabase" class="title">Uses of Class<br>io.github.pitzzahh.atm.dao.InDatabase</h1>
</div>
No usage of io.github.pitzzahh.atm.dao.AtmDAOImplementation</main>
No usage of io.github.pitzzahh.atm.dao.InDatabase</main>
<footer role="contentinfo">
<hr>
<p class="legal-copy"><small>Copyright &#169; 2022. All rights reserved.</small></p>
Expand Down
29 changes: 23 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,39 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.22</version>
<version>5.3.23</version>
</dependency>

<dependency>
<groupId>io.github.pitzzahh</groupId>
<artifactId>util-classes</artifactId>
<version>1.0.7</version>
<version>1.0.11</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<version>5.9.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version>
<exclusions>
<exclusion>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand All @@ -57,7 +74,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -71,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.4.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -85,7 +102,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
31 changes: 26 additions & 5 deletions src/main/java/io/github/pitzzahh/atm/dao/AtmDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.function.BiFunction;
import io.github.pitzzahh.atm.entity.Loan;
import io.github.pitzzahh.atm.entity.Client;
import io.github.pitzzahh.atm.entity.Message;
import io.github.pitzzahh.atm.service.AtmService;
import com.github.pitzzahh.utilities.classes.enums.Status;
import io.github.pitzzahh.util.utilities.classes.enums.Status;

/**
* interface used to access the database. Implemented by {@code AtmDAOImplementation}.
* interface used to access the database. Implemented by {@code InDatabase}.
* Used in {@code AtmService}
* @see AtmDAOImplementation
* @see InDatabase
* @see AtmService
*/
public interface AtmDAO {
Expand All @@ -31,7 +32,9 @@ public interface AtmDAO {
* @see Consumer
* @see DataSource
*/
Consumer<DataSource> setDataSource() throws RuntimeException;
default Consumer<DataSource> setDataSource() throws RuntimeException {
return null;
}

/**
* Function that supplies a {@code Map<String, Client>}.
Expand Down Expand Up @@ -211,5 +214,23 @@ public interface AtmDAO {
* @see List
* @see Message
*/
Function<String, Map<String, List<Message>>> getMessage();
default Function<String, Map<String, List<Message>>> getMessage() {
return accountNumber -> {
var client = getClientByAccountNumber().apply(accountNumber);
var check = getAllLoans()
.get()
.values()
.stream()
.flatMap(Collection::stream)
.allMatch(a -> a.accountNumber().equals(accountNumber) && ( a.pending() && !a.isDeclined() ));
if (check) throw new IllegalStateException("THERE ARE NO MESSAGES AT THE MOMENT");
return getAllLoans().get()
.values()
.stream()
.flatMap(Collection::stream)
.filter(l -> !l.pending() || l.isDeclined())
.map(loan -> new Message(loan, client, loan.pending() && loan.isDeclined()))
.collect(Collectors.groupingBy(message -> message.loan().accountNumber()));
};
}
}
Loading