diff --git a/pom.xml b/pom.xml
index 0a99788..e9f4931 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,14 +14,14 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.4.RELEASE
+ 1.5.2.RELEASE
UTF-8
UTF-8
- 1.7
+ 1.8
@@ -38,17 +38,30 @@
spring-boot-starter-test
test
+
+
+
+
+
+
+
+
+
+
- org.hsqldb
- hsqldb
- runtime
+ com.h2database
+ h2
+ compile
-
javax.inject
javax.inject
1
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
diff --git a/src/main/java/io/zipcoder/ZcwbankApplication.java b/src/main/java/io/zipcoder/ZcwbankApplication.java
index 60df46b..82d7060 100644
--- a/src/main/java/io/zipcoder/ZcwbankApplication.java
+++ b/src/main/java/io/zipcoder/ZcwbankApplication.java
@@ -1,12 +1,26 @@
package io.zipcoder;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+
+import javax.servlet.annotation.WebServlet;
@SpringBootApplication
+//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class ZcwbankApplication {
public static void main(String[] args) {
SpringApplication.run(ZcwbankApplication.class, args);
}
+
+// @Bean
+// ServletRegistrationBean h2servletRegistration(){
+// ServletRegistrationBean registrationBean = new ServletRegistrationBean( new org.h2.server.web.WebServlet());
+// registrationBean.addUrlMappings("/console/*");
+// return registrationBean;
+// }
}
diff --git a/src/main/java/io/zipcoder/controllers/AccountController.java b/src/main/java/io/zipcoder/controllers/AccountController.java
new file mode 100644
index 0000000..fb5dd71
--- /dev/null
+++ b/src/main/java/io/zipcoder/controllers/AccountController.java
@@ -0,0 +1,45 @@
+package io.zipcoder.controllers;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.services.AccountService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+
+@RestController
+public class AccountController {
+
+ @Autowired
+ private AccountService accountService;
+
+ @RequestMapping(value = "/accounts", method = RequestMethod.GET)
+ public ResponseEntity> getAllAccounts(){
+ return accountService.getAllAccounts();
+ }
+
+ @RequestMapping(value = "/accounts/{id}", method = RequestMethod.GET)
+ public ResponseEntity getAccountById(@PathVariable Long id){
+ return accountService.getAccountById(id);
+ }
+
+ @RequestMapping(value = "/customers/{customerId}/accounts", method = RequestMethod.GET)
+ public ResponseEntity> getAllAccountsByCustomer(@PathVariable Long customerId){
+ return accountService.getAllAccountsByCustomer(customerId);
+ }
+
+ @RequestMapping(value = "/customers/{customerId}/accounts", method = RequestMethod.POST)
+ public ResponseEntity createAccount(@RequestBody Account account, @PathVariable Long customerId){
+ return accountService.createAccount(account, customerId);
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.PUT)
+ public ResponseEntity updateAccount(@PathVariable Long accountId, @RequestBody Account account){
+ return accountService.updateAccount(accountId, account);
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.DELETE)
+ public ResponseEntity deleteAccount(@PathVariable Long accountId){
+ return accountService.deleteAccount(accountId);
+ }
+}
diff --git a/src/main/java/io/zipcoder/controllers/BillController.java b/src/main/java/io/zipcoder/controllers/BillController.java
new file mode 100644
index 0000000..e9dea5d
--- /dev/null
+++ b/src/main/java/io/zipcoder/controllers/BillController.java
@@ -0,0 +1,49 @@
+package io.zipcoder.controllers;
+
+import io.zipcoder.entities.Bill;
+import io.zipcoder.services.BillService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class BillController {
+
+ private BillService billService;
+
+ @Autowired
+ public BillController(BillService billService) {
+ this.billService = billService;
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}/bills", method = RequestMethod.GET)
+ public ResponseEntity> getBillsByAccount(@PathVariable Long accountId) {
+ return this.billService.getBillsByAccount(accountId);
+ }
+
+ @RequestMapping(value = "/bills/{billId}/bills", method = RequestMethod.GET)
+ public ResponseEntity getBillByBillId(@PathVariable Long billId) {
+ return this.billService.getBillByBillId(billId);
+ }
+
+ @RequestMapping(value = "/customers/{customerId}/bills", method = RequestMethod.GET)
+ public ResponseEntity> getBillsByCustomerId(@PathVariable Long customerId) {
+ return this.billService.getBillsByCustomerId(customerId);
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}/bills", method = RequestMethod.POST)
+ public ResponseEntity createBill(@PathVariable Long accountId, @RequestBody Bill bill) {
+ return this.billService.createBill(accountId, bill);
+ }
+
+ @RequestMapping(value = "/bills/{billId}", method = RequestMethod.PUT)
+ public ResponseEntity updateBill(@PathVariable Long billId, @RequestBody Bill bill) {
+ return this.billService.updateBill(billId, bill);
+ }
+
+ @RequestMapping(value = "/bills/{billId}", method = RequestMethod.DELETE)
+ public ResponseEntity deleteBill(@PathVariable Long billId) {
+ return this.billService.deleteBill(billId);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/io/zipcoder/controllers/CustomerController.java b/src/main/java/io/zipcoder/controllers/CustomerController.java
new file mode 100644
index 0000000..285046a
--- /dev/null
+++ b/src/main/java/io/zipcoder/controllers/CustomerController.java
@@ -0,0 +1,44 @@
+package io.zipcoder.controllers;
+
+import io.zipcoder.entities.Customer;
+import io.zipcoder.services.CustomerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class CustomerController {
+
+ private CustomerService customerService;
+
+ @Autowired
+ public CustomerController(CustomerService customerService) {
+ this.customerService = customerService;
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}/customer", method = RequestMethod.GET)
+ public ResponseEntity getCustomerByAccountId(@PathVariable Long accountId) {
+ return customerService.getCustomerByAccountId(accountId);
+ }
+
+ @RequestMapping(value = "/customers", method = RequestMethod.GET)
+ public ResponseEntity> getAllCustomers() {
+ return customerService.getAllCustomers();
+ }
+
+ @RequestMapping(value = "/customers/{id}", method = RequestMethod.GET)
+ public ResponseEntity getCustomerByCustomerId(@PathVariable Long id) {
+ return customerService.getCustomerByCustomerId(id);
+ }
+
+ @RequestMapping(value = "/customers", method = RequestMethod.POST)
+ public ResponseEntity createCustomer(@RequestBody Customer customer) {
+ return customerService.createCustomer(customer);
+ }
+
+ @RequestMapping(value = "/customers/{customerId}", method = RequestMethod.PUT)
+ public ResponseEntity updateCustomer(@PathVariable Long customerId, @RequestBody Customer customer) {
+ return customerService.updateCustomer(customerId, customer);
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/controllers/DepositController.java b/src/main/java/io/zipcoder/controllers/DepositController.java
new file mode 100644
index 0000000..e2ab89c
--- /dev/null
+++ b/src/main/java/io/zipcoder/controllers/DepositController.java
@@ -0,0 +1,43 @@
+package io.zipcoder.controllers;
+
+import io.zipcoder.entities.Deposit;
+import io.zipcoder.services.DepositService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class DepositController {
+
+ private DepositService depositService;
+
+ @Autowired
+ public DepositController(DepositService depositService) {
+ this.depositService = depositService;
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}/deposits", method = RequestMethod.GET)
+ public ResponseEntity> getAllDeposits(@PathVariable Long accountId) {
+ return this.depositService.getAllDepositsFromAccount(accountId);
+ }
+
+ @RequestMapping(value = "/deposits/{depositId}", method = RequestMethod.GET)
+ public ResponseEntity getDepositById(@PathVariable Long depositId) {
+ return this.depositService.getDepositById(depositId);
+ }
+
+ @RequestMapping(value = "/accounts/{accountId}/deposits", method = RequestMethod.POST)
+ public ResponseEntity createDeposit(@PathVariable Long accountId, @RequestBody Deposit deposit) {
+ return this.depositService.createDeposit(accountId, deposit);
+ }
+
+ @RequestMapping(value = "/deposits/{depositId}", method = RequestMethod.PUT)
+ public ResponseEntity updateDeposit(@PathVariable Long depositId, @RequestBody Deposit deposit) {
+ return this.depositService.updateDeposit(depositId, deposit);
+ }
+
+ @RequestMapping(value = "/deposits/{depositId}", method = RequestMethod.DELETE)
+ public ResponseEntity deleteDeposit(@PathVariable Long depositId) {
+ return this.depositService.deleteDeposit(depositId);
+ }
+}
diff --git a/src/main/java/io/zipcoder/controllers/WithdrawalController.java b/src/main/java/io/zipcoder/controllers/WithdrawalController.java
new file mode 100644
index 0000000..e2de4e0
--- /dev/null
+++ b/src/main/java/io/zipcoder/controllers/WithdrawalController.java
@@ -0,0 +1,35 @@
+package io.zipcoder.controllers;
+
+import io.zipcoder.entities.Withdrawal;
+import io.zipcoder.services.WithdrawalService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class WithdrawalController {
+
+ @Autowired
+ private WithdrawalService withdrawalService;
+
+ @RequestMapping(value = "/accounts/{accountId}/withdrawals", method = RequestMethod.GET)
+ public ResponseEntity> getAllWithdrawalsFromAccountId(@PathVariable Long accountId){
+ return withdrawalService.getAllWithdrawalsFromAccountId(accountId);
+ }
+ @RequestMapping(value = "/withdrawals/{withdrawalId}", method = RequestMethod.GET)
+ public ResponseEntity getWithdrawalsByWithdrawalId(@PathVariable Long withdrawalId){
+ return withdrawalService.getWithdrawalsByWithdrawalId(withdrawalId);
+ }
+ @RequestMapping(value = "/accounts/{accountId}/withdrawals", method = RequestMethod.POST)
+ public ResponseEntity createWithdrawal(@PathVariable Long accountId, @RequestBody Withdrawal withdrawal){
+ return withdrawalService.createWithdrawal(accountId, withdrawal);
+ }
+ @RequestMapping(value = "/withdrawals/{withdrawalId}", method = RequestMethod.PUT)
+ public ResponseEntity updateWithdrawal(@PathVariable Long withdrawalId, @RequestBody Withdrawal withdrawal){
+ return withdrawalService.updateWithdrawal(withdrawalId, withdrawal);
+ }
+ @RequestMapping(value = "/withdrawals/{withdrawalId}", method = RequestMethod.DELETE)
+ public ResponseEntity deleteWithdrawal(@PathVariable Long withdrawalId){
+ return withdrawalService.deleteWithdrawal(withdrawalId);
+ }
+}
diff --git a/src/main/java/io/zipcoder/entities/Account.java b/src/main/java/io/zipcoder/entities/Account.java
new file mode 100644
index 0000000..b08f1b0
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Account.java
@@ -0,0 +1,88 @@
+package io.zipcoder.entities;
+
+import io.zipcoder.utilities.AccountType;
+
+import javax.persistence.*;
+
+@Entity
+public class Account {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "ACCOUNT_ID")
+ private Long id;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "ACCOUNT_TYPE")
+ private AccountType type;
+
+ @Column(name = "NICKNAME")
+ private String nickname;
+
+ @Column(name = "REWARDS_POINTS")
+ private Integer rewards;
+
+ @Column(name = "ACCOUNT_BALANCE")
+ private Double balance;
+
+ @ManyToOne
+ @JoinColumn(name = "CUSTOMER_ID")
+ private Customer customer;
+
+ public Account(){}
+
+ public Account(String nickname, AccountType type, Double balance, Customer customer){
+ this.nickname = nickname;
+ this.type = type;
+ this.balance = balance;
+ this.customer = customer;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public AccountType getType() {
+ return this.type;
+ }
+
+ public void setType(AccountType type) {
+ this.type = type;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public Integer getRewards() {
+ return rewards;
+ }
+
+ public void setRewards(Integer rewards) {
+ this.rewards = rewards;
+ }
+
+ public Double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(Double balance) {
+ this.balance = balance;
+ }
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+}
diff --git a/src/main/java/io/zipcoder/entities/Address.java b/src/main/java/io/zipcoder/entities/Address.java
new file mode 100644
index 0000000..37b68d3
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Address.java
@@ -0,0 +1,79 @@
+package io.zipcoder.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Address {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "ADDRESS_ID")
+ private Long id;
+
+ @Column(name = "STREET_NUMBER")
+ private String streetNumber;
+
+ @Column(name = "STREET_NAME")
+ private String streetName;
+
+ @Column(name = "CITY")
+ private String city;
+
+ @Column(name = "STATE")
+ private String state;
+
+ @Column(name = "ZIP")
+ private String zip;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreetNumber() {
+ return streetNumber;
+ }
+
+ public void setStreetNumber(String streetNumber) {
+ this.streetNumber = streetNumber;
+ }
+
+ public String getStreetName() {
+ return streetName;
+ }
+
+ public void setStreetName(String streetName) {
+ this.streetName = streetName;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getZip() {
+ return zip;
+ }
+
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+}
diff --git a/src/main/java/io/zipcoder/entities/Bill.java b/src/main/java/io/zipcoder/entities/Bill.java
new file mode 100644
index 0000000..88ebfe6
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Bill.java
@@ -0,0 +1,124 @@
+package io.zipcoder.entities;
+
+import io.zipcoder.utilities.BillStatus;
+
+import javax.persistence.*;
+
+@Entity
+public class Bill {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "BILL_ID")
+ private Long id;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "STATUS")
+ private BillStatus status;
+
+ @Column(name = "PAYEE")
+ private String payee;
+
+ @Column(name = "NICKNAME")
+ private String nickname;
+
+ @Column(name = "CREATION_DATE")
+ private String creationDate;
+
+ @Column(name = "PAYMENT DATE")
+ private String paymentDate;
+
+ @Column(name = "RECURRING_DATE")
+ private Integer recurringDate;
+
+ @Column(name = "UPCOMING_PAYMENT_DATE")
+ private String upcomingPaymentDate;
+
+ @Column(name = "PAYMENT_AMOUNT")
+ private Double paymentAmount;
+
+ @OneToOne(targetEntity = Account.class)
+ @JoinColumn(name = "ACCOUNT_ID")
+ private Account account;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public BillStatus getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(BillStatus status) {
+ this.status = status;
+ }
+
+ public String getPayee() {
+ return payee;
+ }
+
+ public void setPayee(String payee) {
+ this.payee = payee;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public String getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(String creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getPaymentDate() {
+ return paymentDate;
+ }
+
+ public void setPaymentDate(String paymentDate) {
+ this.paymentDate = paymentDate;
+ }
+
+ public Integer getRecurringDate() {
+ return recurringDate;
+ }
+
+ public void setRecurringDate(Integer recurringDate) {
+ this.recurringDate = recurringDate;
+ }
+
+ public String getUpcomingPaymentDate() {
+ return upcomingPaymentDate;
+ }
+
+ public void setUpcomingPaymentDate(String upcomingPaymentDate) {
+ this.upcomingPaymentDate = upcomingPaymentDate;
+ }
+
+ public Double getPaymentAmount() {
+ return paymentAmount;
+ }
+
+ public void setPaymentAmount(Double paymentAmount) {
+ this.paymentAmount = paymentAmount;
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+ public void setAccount(Account account) {
+ this.account = account;
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/entities/Customer.java b/src/main/java/io/zipcoder/entities/Customer.java
new file mode 100644
index 0000000..d06b695
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Customer.java
@@ -0,0 +1,56 @@
+package io.zipcoder.entities;
+
+import javax.persistence.*;
+import java.util.Set;
+
+@Entity
+public class Customer {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "CUSTOMER_ID")
+ private Long id;
+
+ @Column(name = "FIRST_NAME")
+ private String firstName;
+
+ @Column(name = "LAST_NAME")
+ private String lastName;
+
+ @OneToMany
+ @Column(name = "ADDRESS")
+ private Set addresses;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public Set getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(Set addresses) {
+ this.addresses = addresses;
+ }
+}
diff --git a/src/main/java/io/zipcoder/entities/Deposit.java b/src/main/java/io/zipcoder/entities/Deposit.java
new file mode 100644
index 0000000..8dfe1e0
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Deposit.java
@@ -0,0 +1,106 @@
+package io.zipcoder.entities;
+
+import io.zipcoder.utilities.Medium;
+import io.zipcoder.utilities.TransactionStatus;
+import io.zipcoder.utilities.TransactionType;
+
+import javax.persistence.*;
+
+@Entity
+public class Deposit {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "DEPOSIT_ID")
+ private Long id;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "TRANSACTION_TYPE")
+ private TransactionType type;
+
+ @Column(name = "TRANSACTION_DATE")
+ private String transactionDate;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "TRANSACTION_STATUS")
+ private TransactionStatus status;
+
+ @ManyToOne
+ private Account account;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "MEDIUM")
+ private Medium medium;
+
+ @Column(name = "DEPOSIT_AMOUNT")
+ private Double amount;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public TransactionType getType() {
+ return this.type;
+ }
+
+ public void setType(TransactionType type) {
+ this.type = type;
+ }
+
+ public String getTransactionDate() {
+ return transactionDate;
+ }
+
+ public void setTransactionDate(String transactionDate) {
+ this.transactionDate = transactionDate;
+ }
+
+ public TransactionStatus getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(TransactionStatus status) {
+ this.status = status;
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+ public void setAccount(Account account) {
+ this.account = account;
+ }
+
+ public Medium getMedium() {
+ return this.medium;
+ }
+
+ public void setMedium(Medium medium) {
+ this.medium = medium;
+ }
+
+ public Double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(Double amount) {
+ this.amount = amount;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/src/main/java/io/zipcoder/entities/Withdrawal.java b/src/main/java/io/zipcoder/entities/Withdrawal.java
new file mode 100644
index 0000000..b893eb1
--- /dev/null
+++ b/src/main/java/io/zipcoder/entities/Withdrawal.java
@@ -0,0 +1,108 @@
+package io.zipcoder.entities;
+
+import io.zipcoder.utilities.Medium;
+import io.zipcoder.utilities.TransactionStatus;
+import io.zipcoder.utilities.TransactionType;
+
+
+import javax.persistence.*;
+
+@Entity
+public class Withdrawal {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "WITHDRAWAL_ID")
+ private Long id;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "TRANSACTION_TYPE")
+ private TransactionType type;
+
+ @Column(name = "TRANSACTION_DATE")
+ private String transactionDate;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "TRANSACTION_STATUS")
+ private TransactionStatus status;
+
+ @ManyToOne
+ private Account account;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "MEDIUM")
+ private Medium medium;
+
+ @Column(name = "WITHDRAWAL_AMOUNT")
+ private Double amount;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public TransactionType getType() {
+ return this.type;
+ }
+
+ public void setType(TransactionType type) {
+ this.type = type;
+ }
+
+ public String getTransactionDate() {
+ return transactionDate;
+ }
+
+ public void setTransactionDate(String transactionDate) {
+ this.transactionDate = transactionDate;
+ }
+
+ public TransactionStatus getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(TransactionStatus status) {
+ this.status = status;
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+ public void setAccount(Account account) {
+ this.account = account;
+ }
+
+ public Medium getMedium() {
+ return this.medium;
+ }
+
+ public void setMedium(Medium medium) {
+ this.medium = medium;
+ }
+
+ public Double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(Double amount) {
+ this.amount = amount;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/exceptions/ResourceNotFoundException.java b/src/main/java/io/zipcoder/exceptions/ResourceNotFoundException.java
new file mode 100644
index 0000000..0a8ae41
--- /dev/null
+++ b/src/main/java/io/zipcoder/exceptions/ResourceNotFoundException.java
@@ -0,0 +1,19 @@
+package io.zipcoder.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class ResourceNotFoundException extends RuntimeException {
+ public ResourceNotFoundException() {
+
+ }
+
+ public ResourceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ResourceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/io/zipcoder/repositories/AccountRepo.java b/src/main/java/io/zipcoder/repositories/AccountRepo.java
new file mode 100644
index 0000000..3b186f8
--- /dev/null
+++ b/src/main/java/io/zipcoder/repositories/AccountRepo.java
@@ -0,0 +1,10 @@
+package io.zipcoder.repositories;
+
+import io.zipcoder.entities.Account;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+public interface AccountRepo extends CrudRepository {
+ Iterable findAllAccountsByCustomerId(Long customerId);
+}
diff --git a/src/main/java/io/zipcoder/repositories/BillRepo.java b/src/main/java/io/zipcoder/repositories/BillRepo.java
new file mode 100644
index 0000000..53df895
--- /dev/null
+++ b/src/main/java/io/zipcoder/repositories/BillRepo.java
@@ -0,0 +1,12 @@
+package io.zipcoder.repositories;
+
+import io.zipcoder.entities.Bill;
+import org.springframework.data.repository.CrudRepository;
+
+public interface BillRepo extends CrudRepository {
+ Iterable findAllBillsByAccountId(Long accountId);
+
+ Iterable findAllBillsByAccount_Customer_Id(Long customerId);
+
+
+}
diff --git a/src/main/java/io/zipcoder/repositories/CustomerRepo.java b/src/main/java/io/zipcoder/repositories/CustomerRepo.java
new file mode 100644
index 0000000..06d84ac
--- /dev/null
+++ b/src/main/java/io/zipcoder/repositories/CustomerRepo.java
@@ -0,0 +1,10 @@
+package io.zipcoder.repositories;
+
+import io.zipcoder.entities.Customer;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface CustomerRepo extends CrudRepository {
+
+
+}
diff --git a/src/main/java/io/zipcoder/repositories/DepositRepo.java b/src/main/java/io/zipcoder/repositories/DepositRepo.java
new file mode 100644
index 0000000..6152700
--- /dev/null
+++ b/src/main/java/io/zipcoder/repositories/DepositRepo.java
@@ -0,0 +1,9 @@
+package io.zipcoder.repositories;
+
+import io.zipcoder.entities.Deposit;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface DepositRepo extends CrudRepository {
+ Iterable findByAccountId(Long accountId);
+}
diff --git a/src/main/java/io/zipcoder/repositories/WithdrawalRepo.java b/src/main/java/io/zipcoder/repositories/WithdrawalRepo.java
new file mode 100644
index 0000000..abccc45
--- /dev/null
+++ b/src/main/java/io/zipcoder/repositories/WithdrawalRepo.java
@@ -0,0 +1,11 @@
+package io.zipcoder.repositories;
+
+import io.zipcoder.entities.Withdrawal;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface WithdrawalRepo extends CrudRepository {
+
+ Iterable findByAccountId(Long accountId);
+
+}
diff --git a/src/main/java/io/zipcoder/services/AccountService.java b/src/main/java/io/zipcoder/services/AccountService.java
new file mode 100644
index 0000000..e2845b5
--- /dev/null
+++ b/src/main/java/io/zipcoder/services/AccountService.java
@@ -0,0 +1,62 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.exceptions.ResourceNotFoundException;
+import io.zipcoder.repositories.CustomerRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AccountService {
+
+ private AccountRepo accountRepo;
+ private CustomerRepo customerRepo;
+
+ @Autowired
+ public AccountService(AccountRepo accountRepo, CustomerRepo customerRepo){
+ this.accountRepo = accountRepo;
+ this.customerRepo = customerRepo;
+ }
+
+ public ResponseEntity> getAllAccounts() {
+ return new ResponseEntity<>(accountRepo.findAll(), HttpStatus.OK);
+ }
+
+ public ResponseEntity getAccountById(Long accountId) {
+ Account account = accountRepo.findOne(accountId);
+ verifyAccount(accountId);
+ return new ResponseEntity<>(account, HttpStatus.OK);
+ }
+
+ public ResponseEntity> getAllAccountsByCustomer(Long customerId) {
+ return new ResponseEntity<>(accountRepo.findAllAccountsByCustomerId(customerId), HttpStatus.OK);
+ }
+
+ public ResponseEntity createAccount(Account account, Long customerId) {
+ Customer customer = customerRepo.findOne(customerId);
+ account.setCustomer(customer);
+ account = accountRepo.save(account);
+ return new ResponseEntity<>(account, HttpStatus.CREATED);
+ }
+
+ public ResponseEntity updateAccount(Long accountId, Account account) {
+// verifyAccount(accountId);
+ return new ResponseEntity<>(accountRepo.save(account), HttpStatus.OK);
+ }
+
+ public ResponseEntity> deleteAccount(Long accountId) {
+ accountRepo.delete(accountId);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ private void verifyAccount(Long accountId) throws ResourceNotFoundException {
+ Account account = accountRepo.findOne(accountId);
+ if(account == null) {
+ throw new ResourceNotFoundException("Account with id " + accountId + " not found");
+ }
+ }
+}
diff --git a/src/main/java/io/zipcoder/services/BillService.java b/src/main/java/io/zipcoder/services/BillService.java
new file mode 100644
index 0000000..04832f4
--- /dev/null
+++ b/src/main/java/io/zipcoder/services/BillService.java
@@ -0,0 +1,54 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Bill;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.BillRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BillService {
+
+ private BillRepo billRepo;
+ private AccountRepo accountRepo;
+
+ @Autowired
+ public BillService(BillRepo billRepo, AccountRepo accountRepo){
+ this.billRepo = billRepo;
+ this.accountRepo = accountRepo;
+ }
+
+ public ResponseEntity> getBillsByAccount(Long accountId) {
+ return new ResponseEntity<>(billRepo.findAllBillsByAccountId(accountId), HttpStatus.OK);
+ }
+
+ public ResponseEntity getBillByBillId(Long billId) {
+ return new ResponseEntity<>(billRepo.findOne(billId), HttpStatus.OK);
+ }
+
+ public ResponseEntity> getBillsByCustomerId(Long customerId) {
+ return new ResponseEntity<>(billRepo.findAllBillsByAccount_Customer_Id(customerId), HttpStatus.OK);
+ }
+
+ public ResponseEntity createBill(Long accountId, Bill bill) {
+ Account account = accountRepo.findOne(accountId);
+ bill.setAccount(account);
+ Bill savedBill = billRepo.save(bill);
+ return new ResponseEntity<>(savedBill, HttpStatus.CREATED);
+ }
+
+ public ResponseEntity updateBill(Long billId, Bill bill) {
+ bill.setId(billId);
+ Bill savedBill = billRepo.save(bill);
+ return new ResponseEntity<>(savedBill, HttpStatus.OK);
+ }
+
+ public ResponseEntity deleteBill(Long billId) {
+ billRepo.delete(billId);
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/services/CustomerService.java b/src/main/java/io/zipcoder/services/CustomerService.java
new file mode 100644
index 0000000..250a5e7
--- /dev/null
+++ b/src/main/java/io/zipcoder/services/CustomerService.java
@@ -0,0 +1,58 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.exceptions.ResourceNotFoundException;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.CustomerRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CustomerService {
+
+ private CustomerRepo customerRepo;
+ private AccountRepo accountRepo;
+
+ @Autowired
+ public CustomerService(CustomerRepo customerRepo, AccountRepo accountRepo) {
+ this.customerRepo = customerRepo;
+ this.accountRepo = accountRepo;
+ }
+
+ public ResponseEntity getCustomerByAccountId(Long accountId) {
+ Account account = accountRepo.findOne(accountId);
+ Customer customer = account.getCustomer();
+ return new ResponseEntity<>(customer, HttpStatus.OK);
+ }
+
+ public ResponseEntity> getAllCustomers() {
+ return new ResponseEntity<>(customerRepo.findAll(), HttpStatus.OK);
+ }
+
+ public ResponseEntity getCustomerByCustomerId(Long id) {
+// verifyCustomer(id);
+ return new ResponseEntity<>(customerRepo.findOne(id), HttpStatus.OK);
+ }
+
+ public ResponseEntity createCustomer(Customer customer) {
+ return new ResponseEntity<>(customerRepo.save(customer), HttpStatus.CREATED);
+ }
+
+ public ResponseEntity updateCustomer(Long customerId, Customer customer) {
+// verifyCustomer(customerId);
+ return new ResponseEntity<>(customerRepo.save(customer), HttpStatus.OK);
+ }
+
+ private void verifyCustomer(Long customerId) throws ResourceNotFoundException {
+ Customer customer = customerRepo.findOne(customerId);
+ if(customer == null) {
+ throw new ResourceNotFoundException("Account with id " + customerId + " not found");
+ }
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/services/DepositService.java b/src/main/java/io/zipcoder/services/DepositService.java
new file mode 100644
index 0000000..ca9b97c
--- /dev/null
+++ b/src/main/java/io/zipcoder/services/DepositService.java
@@ -0,0 +1,37 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Deposit;
+import io.zipcoder.repositories.DepositRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DepositService {
+
+ @Autowired
+ private DepositRepo depositRepo;
+
+ public ResponseEntity> getAllDepositsFromAccount(Long accountId) {
+ return new ResponseEntity<>(depositRepo.findByAccountId(accountId), HttpStatus.OK);
+ }
+
+ public ResponseEntity getDepositById(Long depositId) {
+ return new ResponseEntity<>(depositRepo.findOne(depositId), HttpStatus.OK);
+ }
+
+ public ResponseEntity createDeposit(Long accountId, Deposit deposit) {
+ return new ResponseEntity<>(depositRepo.save(deposit), HttpStatus.CREATED);
+ }
+
+ public ResponseEntity updateDeposit(Long depositId, Deposit deposit) {
+ return new ResponseEntity<>(depositRepo.save(deposit), HttpStatus.OK);
+ }
+
+ public ResponseEntity deleteDeposit(Long depositId) {
+ depositRepo.delete(depositId);
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/services/WithdrawalService.java b/src/main/java/io/zipcoder/services/WithdrawalService.java
new file mode 100644
index 0000000..6a9efba
--- /dev/null
+++ b/src/main/java/io/zipcoder/services/WithdrawalService.java
@@ -0,0 +1,52 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.entities.Withdrawal;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.WithdrawalRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import java.util.Optional;
+
+@Service
+public class WithdrawalService {
+
+ private WithdrawalRepo withdrawalRepo;
+ private AccountRepo accountRepo;
+
+
+ @Autowired
+ public WithdrawalService(WithdrawalRepo withdrawalRepo, AccountRepo accountRepo){
+ this.withdrawalRepo = withdrawalRepo;
+ this.accountRepo = accountRepo;
+ }
+
+ public ResponseEntity> getAllWithdrawalsFromAccountId(Long accountId) {
+ return new ResponseEntity<>(withdrawalRepo.findByAccountId(accountId), HttpStatus.OK);
+ }
+
+ public ResponseEntity getWithdrawalsByWithdrawalId(Long withdrawalId) {
+ return new ResponseEntity<>(withdrawalRepo.findOne(withdrawalId), HttpStatus.OK);
+ }
+
+ public ResponseEntity createWithdrawal(Long accountId, Withdrawal withdrawal) {
+ withdrawal.setAccount(accountRepo.findOne(accountId));
+ Withdrawal newWithdrawal = withdrawalRepo.save(withdrawal);
+ return new ResponseEntity<>(newWithdrawal, HttpStatus.CREATED);
+ }
+
+ public ResponseEntity updateWithdrawal(Long withdrawalId, Withdrawal withdrawal) {
+ withdrawal.setId(withdrawalId);
+ Withdrawal newWithdrawal = withdrawalRepo.save(withdrawal);
+ return new ResponseEntity<>(newWithdrawal, HttpStatus.OK);
+ }
+
+ public ResponseEntity deleteWithdrawal(Long withdrawalId) {
+ withdrawalRepo.delete(withdrawalId);
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+}
diff --git a/src/main/java/io/zipcoder/utilities/AccountType.java b/src/main/java/io/zipcoder/utilities/AccountType.java
new file mode 100644
index 0000000..b7b3ad7
--- /dev/null
+++ b/src/main/java/io/zipcoder/utilities/AccountType.java
@@ -0,0 +1,26 @@
+package io.zipcoder.utilities;
+
+public enum AccountType {
+
+ SAVINGS,
+ CHECKING,
+ CREDIT
+
+// SAVINGS("Savings"),
+// CHECKING("Checking"),
+// CREDIT("Credit");
+
+// private String type;
+//
+// AccountType(String type) {
+// this.type = type;
+// }
+//
+// public String getValue() {
+// return type;
+// }
+//
+// public void setValue(String type) {
+// this.type = type;
+// }
+}
diff --git a/src/main/java/io/zipcoder/utilities/BillStatus.java b/src/main/java/io/zipcoder/utilities/BillStatus.java
new file mode 100644
index 0000000..5fcc57c
--- /dev/null
+++ b/src/main/java/io/zipcoder/utilities/BillStatus.java
@@ -0,0 +1,28 @@
+package io.zipcoder.utilities;
+
+public enum BillStatus {
+
+ PENDING,
+ CANCELLED,
+ COMPLETED,
+ RECURRING
+
+// PENDING("Pending"),
+// CANCELLED("Cancelled"),
+// COMPLETED("Completed"),
+// RECURRING("Recurring");
+
+// private String status;
+//
+// BillStatus(String status) {
+// this.status = status;
+// }
+//
+// public String getValue() {
+// return status;
+// }
+//
+// public void setValue(String status) {
+// this.status = status;
+// }
+}
diff --git a/src/main/java/io/zipcoder/utilities/Medium.java b/src/main/java/io/zipcoder/utilities/Medium.java
new file mode 100644
index 0000000..010f65e
--- /dev/null
+++ b/src/main/java/io/zipcoder/utilities/Medium.java
@@ -0,0 +1,24 @@
+package io.zipcoder.utilities;
+
+public enum Medium {
+
+ BALANCE,
+ REWARDS
+
+// BALANCE("Balance"),
+// REWARDS("Rewards");
+//
+// private String value;
+//
+// Medium(String value) {
+// this.value = value;
+// }
+//
+// public String getValue() {
+// return value;
+// }
+//
+// public void setValue(String value) {
+// this.value = value;
+// }
+}
diff --git a/src/main/java/io/zipcoder/utilities/TransactionStatus.java b/src/main/java/io/zipcoder/utilities/TransactionStatus.java
new file mode 100644
index 0000000..72e96df
--- /dev/null
+++ b/src/main/java/io/zipcoder/utilities/TransactionStatus.java
@@ -0,0 +1,26 @@
+package io.zipcoder.utilities;
+
+public enum TransactionStatus {
+
+ PENDING,
+ CANCELLED,
+ COMPLETED
+
+// PENDING("Pending"),
+// CANCELLED("Cancelled"),
+// COMPLETED("Completed");
+//
+// private String status;
+//
+// TransactionStatus(String status) {
+// this.status = status;
+// }
+//
+// public String getValue() {
+// return status;
+// }
+//
+// public void setValue(String status) {
+// this.status = status;
+// }
+}
diff --git a/src/main/java/io/zipcoder/utilities/TransactionType.java b/src/main/java/io/zipcoder/utilities/TransactionType.java
new file mode 100644
index 0000000..f484c73
--- /dev/null
+++ b/src/main/java/io/zipcoder/utilities/TransactionType.java
@@ -0,0 +1,26 @@
+package io.zipcoder.utilities;
+
+public enum TransactionType {
+
+ P2P,
+ DEPOSIT,
+ WITHDRAWAL
+
+// P2P("P2P"),
+// DEPOSIT("Deposit"),
+// WITHDRAWAL("Withdrawal");
+//
+// private String type;
+//
+// TransactionType(String type) {
+// this.type = type;
+// }
+//
+// public String getValue() {
+// return type;
+// }
+//
+// public void setValue(String type) {
+// this.type = type;
+// }
+}
diff --git a/src/main/resources/application-h2.properties b/src/main/resources/application-h2.properties
new file mode 100644
index 0000000..abb367f
--- /dev/null
+++ b/src/main/resources/application-h2.properties
@@ -0,0 +1,4 @@
+#spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
+#spring.datasource.platform=h2
+#spring.jpa.hibernate.ddl-auto=none
+#spring.datasource.continue-on-error=true
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e69de29..5b41581 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+#spring.profiles.active=h2
+#logging.level.org.springframework.boot.context.embedded=INFO
+#spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
diff --git a/src/main/resources/schema-h2.sql b/src/main/resources/schema-h2.sql
new file mode 100644
index 0000000..313a023
--- /dev/null
+++ b/src/main/resources/schema-h2.sql
@@ -0,0 +1,66 @@
+-- DROP TABLE IF EXISTS ACCOUNT;
+--
+-- CREATE TABLE ACCOUNT (
+-- ACCOUNT_ID INT NOT NULL AUTO_INCREMENT,
+-- FIRST_NAME VARCHAR2(255) NOT NULL DEFAULT '',
+-- LAST_NAME VARCHAR2(255) NOT NULL DEFAULT '',
+-- MOBILE VARCHAR2(20) NOT NULL DEFAULT '',
+-- BIRTHDAY DATE DEFAULT NULL,
+-- HOME_ID SMALLINT DEFAULT NULL,
+-- PRIMARY KEY (ID));
+--
+-- ALTER TABLE ACCOUNT
+-- ADD FOREIGN KEY (HOME_ID)
+-- REFERENCES HOME(ID);
+--
+--
+-- DROP TABLE IF EXISTS HOME;
+--
+-- CREATE TABLE HOME (
+-- ID INT NOT NULL AUTO_INCREMENT,
+-- ADDRESS VARCHAR2(255) not null default '',
+-- HOMENUMBER varchar2(255) NOT NULL DEFAULT '',
+-- PRIMARY KEY (ID)
+-- );
+--
+-- DROP TABLE IF EXISTS movies;
+--
+-- CREATE TABLE movies (
+-- id INT PRIMARY KEY AUTO_INCREMENT,
+-- title VARCHAR2(100) NOT NULL UNIQUE,
+-- runtime SMALLINT NOT NULL,
+-- genre VARCHAR2(50),
+-- imdb_score NUMBER(10,1),
+-- rating VARCHAR2(10)
+-- );
+--
+-- -- Tables for in-class example
+--
+-- DROP TABLE IF EXISTS cars;
+--
+-- CREATE TABLE cars (
+-- id INT NOT NULL AUTO_INCREMENT,
+-- make VARCHAR2(50) NOT NULL DEFAULT '',
+-- model VARCHAR2(50) NOT NULL DEFAULT '',
+-- year VARCHAR2(5) NOT NULL DEFAULT '01907',
+-- PRIMARY KEY (id),
+-- CONSTRAINT unique_make_model_year UNIQUE (make, model, year)
+--
+-- );
+--
+-- DROP TABLE IF EXISTS auto_prices;
+--
+-- CREATE TABLE auto_prices (
+-- id INT PRIMARY KEY AUTO_INCREMENT,
+-- car_id INT REFERENCES cars(id),
+-- package VARCHAR2(15) NOT NULL,
+-- price NUMBER(10,2) NOT NULL CHECK(price > 0),
+-- CONSTRAINT unique_package_per_car UNIQUE (car_id, package)
+--
+--
+-- );
+--
+--
+-- DROP SEQUENCE hibernate_sequence;
+--
+-- CREATE SEQUENCE hibernate_sequence;
diff --git a/src/test/java/io/zipcoder/controllers/AccountControllerTest.java b/src/test/java/io/zipcoder/controllers/AccountControllerTest.java
new file mode 100644
index 0000000..e51f028
--- /dev/null
+++ b/src/test/java/io/zipcoder/controllers/AccountControllerTest.java
@@ -0,0 +1,132 @@
+package io.zipcoder.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.services.AccountService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Mockito.*;
+import static org.springframework.http.HttpStatus.OK;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class AccountControllerTest {
+
+ private MockMvc mockMvc;
+
+ @MockBean
+ private AccountService accountService;
+
+ @InjectMocks
+ private AccountController accountController;
+
+ private ObjectMapper om;
+ private Account mockAccount;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.standaloneSetup(accountController).build();
+ om = new ObjectMapper();
+
+ Customer mockCustomer = new Customer();
+
+ mockAccount = new Account();
+ mockAccount.setId(1L);
+ mockAccount.setCustomer(mockCustomer);
+ }
+
+ @Test
+ public void getAllAccountsTest() throws Exception {
+ Iterable accounts = singletonList(mockAccount);
+ ResponseEntity> response = new ResponseEntity<>(accounts, OK);
+
+ when(accountService.getAllAccounts()).thenReturn(response);
+
+ mockMvc.perform(get("/accounts"))
+ .andExpect(status().isOk());
+// .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
+// .andExpect(jsonPath("$", hasSize(2)))
+// .andExpect(jsonPath("$[0].nickname", is("Joey")))
+// .andExpect(jsonPath("$[0].type", is("CHECKING")))
+// .andExpect(jsonPath("$[0].balance", is(500.00)));
+
+ verify(accountService, times(1)).getAllAccounts();
+ }
+
+ @Test
+ public void getAccountByIdTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(mockAccount, OK);
+
+ when(accountService.getAccountById(2L)).thenReturn(response);
+
+ mockMvc.perform(get("/accounts/2"))
+ .andExpect(status().isOk());
+
+ verify(accountService, times(1)).getAccountById(2L);
+ }
+
+ @Test
+ public void getAllAccountsByCustomerTest() throws Exception {
+ Iterable accounts = singletonList(mockAccount);
+ ResponseEntity> response = new ResponseEntity<>(accounts, OK);
+
+ when(accountService.getAllAccountsByCustomer(mockAccount.getCustomer().getId())).thenReturn(response);
+
+ mockMvc.perform(get("/customers/14/accounts")).andExpect(status().isOk());
+
+ verify(accountService, times(1)).getAllAccountsByCustomer(14L);
+ }
+
+ @Test
+ public void createAccountTest() throws Exception {
+ Account newAccount = new Account();
+ Customer someCustomer = new Customer();
+ someCustomer.setId(1L);
+ newAccount.setCustomer(someCustomer);
+
+ String body = om.writeValueAsString(newAccount);
+
+ when(accountService.createAccount(newAccount, someCustomer.getId())).thenReturn(mock(ResponseEntity.class));
+
+
+ mockMvc.perform(post("/customers/1/accounts")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(body))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ public void updateAccountTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(mockAccount, OK);
+ String body = om.writeValueAsString(response);
+
+ when(accountService.updateAccount(isA(Long.class), isA(Account.class))).thenReturn(response);
+
+ mockMvc.perform(put("/accounts/1")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(body)).andExpect(status().isOk());
+ }
+
+ @Test
+ public void deleteAccountTest() throws Exception {
+ mockMvc.perform(delete("/accounts/1")).andExpect(status().isOk());
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/controllers/BillControllerTest.java b/src/test/java/io/zipcoder/controllers/BillControllerTest.java
new file mode 100644
index 0000000..4d2d104
--- /dev/null
+++ b/src/test/java/io/zipcoder/controllers/BillControllerTest.java
@@ -0,0 +1,127 @@
+package io.zipcoder.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Bill;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.services.BillService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.*;
+import static org.springframework.http.MediaType.APPLICATION_JSON;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class BillControllerTest {
+
+ private MockMvc mockMvc;
+ private Bill testBill;
+ private Account testAccount;
+ private Customer testCustomer;
+ private ObjectMapper mapper;
+
+ @MockBean
+ private BillService billService;
+
+ @InjectMocks
+ private BillController billController;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.standaloneSetup(billController).build();
+ testBill = new Bill();
+ testAccount = new Account();
+ testCustomer = new Customer();
+ mapper = new ObjectMapper();
+ }
+
+ @Test
+ public void getBillsByAccountTest() throws Exception {
+ Iterable bills = singletonList(testBill);
+ ResponseEntity> responseEntity = new ResponseEntity<>(bills, HttpStatus.OK);
+
+ when(billService.getBillsByAccount(testAccount.getId())).thenReturn(responseEntity);
+
+ mockMvc.perform(get("/accounts/14/bills"))
+ .andExpect(status().isOk());
+
+ verify(billService, times(1)).getBillsByAccount(isA(Long.class));
+ }
+
+ @Test
+ public void getBillByBillIdTest() throws Exception {
+ ResponseEntity responseEntity = new ResponseEntity<>(testBill, HttpStatus.OK);
+
+ when(billService.getBillByBillId(testBill.getId())).thenReturn(responseEntity);
+
+ mockMvc.perform(get("/bills/7/bills"))
+ .andExpect(status().isOk());
+
+ verify(billService, times(1)).getBillByBillId(isA(Long.class));
+ }
+
+ @Test
+ public void getBillsByCustomerIdTest() throws Exception {
+ Iterable bills = singletonList(testBill);
+ ResponseEntity> responseEntity = new ResponseEntity<>(bills, HttpStatus.OK);
+
+ when(billService.getBillsByCustomerId(testCustomer.getId())).thenReturn(responseEntity);
+
+ mockMvc.perform(get("/customers/3/bills"))
+ .andExpect(status().isOk());
+
+ verify(billService, times(1)).getBillsByCustomerId(isA(Long.class));
+ }
+
+ @Test
+ public void createBillTest() throws Exception {
+ ResponseEntity responseEntity = new ResponseEntity<>(testBill, HttpStatus.CREATED);
+ String body = mapper.writeValueAsString(testBill);
+
+ when(billService.createBill(testAccount.getId(), testBill)).thenReturn(responseEntity);
+
+ mockMvc.perform(post("/accounts/23/bills")
+ .contentType(APPLICATION_JSON)
+ .content(body))
+ .andExpect(status().isOk());
+
+ verify(billService, times(1)).createBill(isA(Long.class), isA(Bill.class));
+ }
+
+ @Test
+ public void updateBillTest() throws Exception {
+ ResponseEntity responseEntity = new ResponseEntity<>(testBill, HttpStatus.OK);
+ String body = mapper.writeValueAsString(testBill);
+
+ when(billService.updateBill(testBill.getId(), testBill)).thenReturn(responseEntity);
+
+ mockMvc.perform(put("/bills/11")
+ .contentType(APPLICATION_JSON)
+ .content(body))
+ .andExpect(status().isOk());
+
+ verify(billService, times(1)).updateBill(isA(Long.class), isA(Bill.class));
+ }
+
+ @Test
+ public void deleteBillTest() throws Exception {
+ mockMvc.perform(delete("/bills/193")).andExpect(status().isOk());
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/controllers/CustomerControllerTest.java b/src/test/java/io/zipcoder/controllers/CustomerControllerTest.java
new file mode 100644
index 0000000..601c42b
--- /dev/null
+++ b/src/test/java/io/zipcoder/controllers/CustomerControllerTest.java
@@ -0,0 +1,119 @@
+package io.zipcoder.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.services.CustomerService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class CustomerControllerTest {
+
+ private MockMvc mockMvc;
+ private ObjectMapper mapper;
+ private Account testAccount;
+ private Customer testCustomer;
+
+ @MockBean
+ private CustomerService customerService;
+
+ @InjectMocks CustomerController customerController;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.standaloneSetup(customerController).build();
+ mapper = new ObjectMapper();
+ testAccount = new Account();
+ testCustomer = new Customer();
+ }
+
+ @Test
+ public void getCustomerByAccountIdTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+
+ when(customerService.getCustomerByAccountId(testAccount.getId())).thenReturn(response);
+
+ mockMvc.perform(get("/accounts/14/customer")).andExpect(status().isOk());
+
+ verify(customerService, times(1)).getCustomerByAccountId(isA(Long.class));
+ }
+
+ @Test
+ public void getAllCustomersTest() throws Exception {
+ Iterable customers = singletonList(testCustomer);
+ ResponseEntity> responseEntity = new ResponseEntity<>(customers, HttpStatus.OK);
+
+ when(customerService.getAllCustomers()).thenReturn(responseEntity);
+
+ mockMvc.perform(get("/customers")).andExpect(status().isOk());
+
+ verify(customerService, times(1)).getAllCustomers();
+ }
+
+
+ @Test
+ public void getCustomerByCustomerIdTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+
+ when(customerService.getCustomerByCustomerId(testCustomer.getId())).thenReturn(response);
+
+ mockMvc.perform(get("/customers/11")).andExpect(status().isOk());
+
+ verify(customerService, times(1)).getCustomerByCustomerId(isA(Long.class));
+ }
+
+ @Test
+ public void createCustomerTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(testCustomer, HttpStatus.CREATED);
+ String body = mapper.writeValueAsString(testCustomer);
+
+ when(customerService.createCustomer(testCustomer)).thenReturn(response);
+
+ mockMvc.perform(post("/customers")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(body))
+ .andExpect(status().isOk());
+
+ verify(customerService, times(1)).createCustomer(isA(Customer.class));
+ }
+
+ @Test
+ public void updateCustomerTest() throws Exception {
+ ResponseEntity response = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+ String body = mapper.writeValueAsString(testCustomer);
+
+ when(customerService.updateCustomer(testCustomer.getId(), testCustomer)).thenReturn(response);
+
+ mockMvc.perform(put("/customers/561")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(body))
+ .andExpect(status().isOk());
+
+ verify(customerService, times(1)).updateCustomer(isA(Long.class), isA(Customer.class));
+ }
+
+}
diff --git a/src/test/java/io/zipcoder/controllers/DepositControllerTest.java b/src/test/java/io/zipcoder/controllers/DepositControllerTest.java
new file mode 100644
index 0000000..1df0083
--- /dev/null
+++ b/src/test/java/io/zipcoder/controllers/DepositControllerTest.java
@@ -0,0 +1,5 @@
+package io.zipcoder.controllers;
+
+public class DepositControllerTest {
+
+}
diff --git a/src/test/java/io/zipcoder/services/AccountServicesTest.java b/src/test/java/io/zipcoder/services/AccountServicesTest.java
new file mode 100644
index 0000000..bec197f
--- /dev/null
+++ b/src/test/java/io/zipcoder/services/AccountServicesTest.java
@@ -0,0 +1,121 @@
+package io.zipcoder.services;
+
+import io.zipcoder.controllers.AccountController;
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.CustomerRepo;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.web.servlet.MockMvc;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.springframework.http.HttpStatus.OK;
+
+
+public class AccountServicesTest {
+
+ @Mock
+ private AccountRepo accountRepo;
+
+ @Mock
+ private CustomerRepo customerRepo;
+
+ @InjectMocks
+ private AccountService accountService;
+
+ private Account testAccount;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ Customer testCustomer = new Customer();
+ testCustomer.setId(1L);
+ testAccount = new Account();
+ testAccount.setId(1L);
+ testAccount.setCustomer(testCustomer);
+ }
+
+ @Test
+ public void getAllAccountsTest() {
+ Iterable accountsList = new ArrayList<>();
+ given(accountRepo.findAll()).willReturn(accountsList);
+
+ ResponseEntity> expected = new ResponseEntity<>(accountsList, OK);
+ ResponseEntity> actual = accountService.getAllAccounts();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAccountsByIdTest() {
+ accountRepo.save(testAccount);
+ when(accountRepo.findOne(1L)).thenReturn(testAccount);
+ ResponseEntity expected = new ResponseEntity<>(testAccount, OK);
+ ResponseEntity actual = accountService.getAccountById(testAccount.getId());
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAllAccountsByCustomerIdTest() {
+ Iterable accountsList = new ArrayList<>();
+ accountRepo.save(testAccount);
+ when(accountRepo.findAllAccountsByCustomerId(testAccount.getCustomer().getId())).thenReturn(accountsList);
+
+ ResponseEntity> expected = new ResponseEntity<>(accountsList, OK);
+ ResponseEntity> actual = accountService.getAllAccountsByCustomer(testAccount.getCustomer().getId());
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void createAccountTest() {
+ Customer testCust = new Customer();
+ testCust.setId(1L);
+ when(customerRepo.findOne(anyLong())).thenReturn(testCust);
+ when(accountRepo.save(any(Account.class))).thenReturn(testAccount);
+
+ ResponseEntity expected = new ResponseEntity<>(testAccount, HttpStatus.CREATED);
+ ResponseEntity actual = accountService.createAccount(testAccount, testAccount.getCustomer().getId());
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void updateAccountTest() {
+
+ when(accountRepo.save(any(Account.class))).thenReturn(testAccount);
+
+ ResponseEntity expected = new ResponseEntity<>(testAccount, HttpStatus.OK);
+ ResponseEntity actual = accountService.updateAccount(testAccount.getId(), testAccount);
+ Assert.assertEquals(expected, actual);
+
+ }
+
+ @Test
+ public void deleteAccountTest() {
+ accountRepo.save(testAccount);
+ accountRepo.delete(1L);
+ when(accountRepo.findOne(1L)).thenReturn(testAccount).thenReturn(null);
+
+ verify(accountRepo, times(1)).delete(1L);
+ }
+}
diff --git a/src/test/java/io/zipcoder/services/BillServiceTest.java b/src/test/java/io/zipcoder/services/BillServiceTest.java
new file mode 100644
index 0000000..e7011d9
--- /dev/null
+++ b/src/test/java/io/zipcoder/services/BillServiceTest.java
@@ -0,0 +1,119 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Bill;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.BillRepo;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SpringRunner.class)
+public class BillServiceTest {
+
+ private Bill testBill;
+ private Account testAccount;
+ private Customer testCustomer;
+
+ @Mock
+ private BillRepo billRepo;
+
+ @Mock
+ private AccountRepo accountRepo;
+
+ @InjectMocks
+ private BillService billService;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ testCustomer = new Customer();
+ testCustomer.setId(11L);
+
+ testAccount = new Account();
+ testAccount.setId(4L);
+ testAccount.setCustomer(testCustomer);
+
+ testBill = new Bill();
+ testBill.setId(7L);
+ testBill.setAccount(testAccount);
+ }
+
+ @Test
+ public void getBillsByAccountTest() {
+ Iterable bills = singletonList(testBill);
+ when(billRepo.findAllBillsByAccountId(isA(Long.class))).thenReturn(bills);
+
+ ResponseEntity> expected = new ResponseEntity<>(bills, HttpStatus.OK);
+ ResponseEntity> actual = billService.getBillsByAccount(testAccount.getId());
+
+ verify(billRepo).findAllBillsByAccountId(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getBillByBillIdTest() {
+ when(billRepo.findOne(isA(Long.class))).thenReturn(testBill);
+ ResponseEntity expected = new ResponseEntity<>(testBill, HttpStatus.OK);
+ ResponseEntity actual = billService.getBillByBillId(testBill.getId());
+ verify(billRepo).findOne(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getBillsByCustomerId() {
+ Iterable bills = singletonList(testBill);
+ when(billRepo.findAllBillsByAccount_Customer_Id(isA(Long.class))).thenReturn(bills);
+ ResponseEntity> expected = new ResponseEntity<>(bills, HttpStatus.OK);
+ ResponseEntity> actual = billService.getBillsByCustomerId(testCustomer.getId());
+ verify(billRepo).findAllBillsByAccount_Customer_Id(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void createBillTest() {
+ when(accountRepo.findOne(isA(Long.class))).thenReturn(testAccount);
+ when(billRepo.save(isA(Bill.class))).thenReturn(testBill);
+
+ ResponseEntity expected = new ResponseEntity<>(testBill, HttpStatus.CREATED);
+ ResponseEntity actual = billService.createBill(testAccount.getId(), testBill);
+
+ verify(billRepo).save(isA(Bill.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void updateBillTest() {
+ when(billRepo.save(isA(Bill.class))).thenReturn(testBill);
+
+ ResponseEntity expected = new ResponseEntity<>(testBill, HttpStatus.OK);
+ ResponseEntity actual = billService.updateBill(testBill.getId(), testBill);
+
+ verify(billRepo).save(isA(Bill.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void deleteBillTest() {
+ ResponseEntity expected = new ResponseEntity(HttpStatus.OK);
+ ResponseEntity actual = billService.deleteBill(testBill.getId());
+ verify(billRepo).delete(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+
+}
diff --git a/src/test/java/io/zipcoder/services/CustomerServiceTest.java b/src/test/java/io/zipcoder/services/CustomerServiceTest.java
new file mode 100644
index 0000000..32b7cee
--- /dev/null
+++ b/src/test/java/io/zipcoder/services/CustomerServiceTest.java
@@ -0,0 +1,110 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.CustomerRepo;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.xml.ws.Response;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+
+@RunWith(SpringRunner.class)
+public class CustomerServiceTest {
+
+ private Customer testCustomer;
+ private Account testAccount;
+
+ @Mock
+ private CustomerRepo customerRepo;
+
+ @Mock
+ private AccountRepo accountRepo;
+
+ @InjectMocks
+ private CustomerService customerService;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ testCustomer = new Customer();
+ testCustomer.setId(7L);
+
+ testAccount = new Account();
+ testAccount.setCustomer(testCustomer);
+ }
+
+ @Test
+ public void getCustomerByAccountIdTest() {
+ when(accountRepo.findOne(isA(Long.class))).thenReturn(testAccount);
+
+ ResponseEntity expected = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+ ResponseEntity actual = customerService.getCustomerByAccountId(testCustomer.getId());
+
+ verify(accountRepo).findOne(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAllCustomersTest() {
+ Iterable customers = singletonList(testCustomer);
+ when(customerRepo.findAll()).thenReturn(customers);
+
+ ResponseEntity> expected = new ResponseEntity<>(customers, HttpStatus.OK);
+ ResponseEntity> actual = customerService.getAllCustomers();
+
+ verify(customerRepo).findAll();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getCustomerByCustomerIdTest() {
+ when(customerRepo.findOne(isA(Long.class))).thenReturn(testCustomer);
+
+ ResponseEntity expected = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+ ResponseEntity actual = customerService.getCustomerByCustomerId(testCustomer.getId());
+
+ verify(customerRepo).findOne(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void createCustomerTest() {
+ when(customerRepo.save(isA(Customer.class))).thenReturn(testCustomer);
+
+ ResponseEntity expected = new ResponseEntity<>(testCustomer, HttpStatus.CREATED);
+ ResponseEntity actual = customerService.createCustomer(testCustomer);
+
+ verify(customerRepo).save(isA(Customer.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void updateCustomerTest() {
+ when(customerRepo.exists(isA(Long.class))).thenReturn(true);
+ when(customerRepo.save(isA(Customer.class))).thenReturn(testCustomer);
+
+ ResponseEntity expected = new ResponseEntity<>(testCustomer, HttpStatus.OK);
+ ResponseEntity actual = customerService.updateCustomer(testCustomer.getId(), testCustomer);
+
+ verify(customerRepo).save(isA(Customer.class));
+ Assert.assertEquals(expected, actual);
+ }
+
+
+}
diff --git a/src/test/java/io/zipcoder/services/DepositServicesTest.java b/src/test/java/io/zipcoder/services/DepositServicesTest.java
new file mode 100644
index 0000000..d37c480
--- /dev/null
+++ b/src/test/java/io/zipcoder/services/DepositServicesTest.java
@@ -0,0 +1,89 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Customer;
+import io.zipcoder.entities.Deposit;
+import io.zipcoder.repositories.DepositRepo;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.xml.ws.Response;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SpringRunner.class)
+public class DepositServicesTest {
+
+ @Mock
+ private DepositRepo depositRepo;
+
+ @InjectMocks
+ private DepositService depositService;
+
+ private Deposit depositTester;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ Customer tester = new Customer();
+ tester.setId(1L);
+ depositTester = new Deposit();
+ depositTester.setId(1L);
+ }
+
+ @Test
+ public void getAllDepositsTest() {
+ Iterable depositsList = singletonList(depositTester);
+ when(depositRepo.findByAccountId(isA(Long.class))).thenReturn(depositsList);
+
+ ResponseEntity> expected = new ResponseEntity<>(depositsList, HttpStatus.OK);
+ ResponseEntity> actual = depositService.getAllDepositsFromAccount(depositTester.getId());
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getDepositsByDepositIdTest() {
+ when(depositRepo.findOne(isA(Long.class))).thenReturn(depositTester);
+ ResponseEntity expected = new ResponseEntity<>(depositTester, HttpStatus.OK);
+ ResponseEntity actual = depositService.getDepositById(depositTester.getId());
+ Assert.assertEquals(expected, actual);
+ verify(depositRepo).findOne(isA(Long.class));
+ }
+
+ @Test
+ public void createDepositTest() {
+ when(depositRepo.findOne(1L)).thenReturn(depositTester);
+ when(depositRepo.save(isA(Deposit.class))).thenReturn(depositTester);
+ ResponseEntity expected = new ResponseEntity<>(depositTester, HttpStatus.CREATED);
+ ResponseEntity actual = depositService.createDeposit(depositTester.getId(), depositTester);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void updateDepositTest() {
+ when(depositRepo.save(isA(Deposit.class))).thenReturn(depositTester);
+ ResponseEntity expected = new ResponseEntity<>(depositTester, HttpStatus.OK);
+ ResponseEntity actual = depositService.updateDeposit(depositTester.getId(), depositTester);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void deleteDepositTest() {
+ ResponseEntity expected = new ResponseEntity(HttpStatus.OK);
+ ResponseEntity actual = depositService.deleteDeposit(depositTester.getId());
+ verify(depositRepo).delete(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/src/test/java/io/zipcoder/services/WithdrawalServiceTest.java b/src/test/java/io/zipcoder/services/WithdrawalServiceTest.java
new file mode 100644
index 0000000..d2bde55
--- /dev/null
+++ b/src/test/java/io/zipcoder/services/WithdrawalServiceTest.java
@@ -0,0 +1,91 @@
+package io.zipcoder.services;
+
+import io.zipcoder.entities.Account;
+import io.zipcoder.entities.Customer;
+import io.zipcoder.entities.Withdrawal;
+import io.zipcoder.repositories.AccountRepo;
+import io.zipcoder.repositories.WithdrawalRepo;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+
+import static java.util.Collections.singletonList;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SpringRunner.class)
+public class WithdrawalServiceTest {
+
+ @Mock
+ private AccountRepo accountRepo;
+
+ @Mock
+ private WithdrawalRepo withdrawalRepo;
+
+ @InjectMocks
+ private WithdrawalService withdrawalService;
+
+ private Withdrawal testWithdrawal;
+ private Account testAccount;
+
+ @Before
+ public void init(){
+ MockitoAnnotations.initMocks(this);
+ Customer testCustomer = new Customer();
+ testCustomer.setId(1L);
+ testWithdrawal = new Withdrawal();
+ testWithdrawal.setId(1L);
+ }
+
+ @Test
+ public void getAllWithdrawalsFromAccountIdTest(){
+ Iterable withdrawalList = singletonList(testWithdrawal);
+ when(withdrawalRepo.findByAccountId(isA(Long.class))).thenReturn(withdrawalList);
+
+ ResponseEntity> expected = new ResponseEntity<>(withdrawalList, HttpStatus.OK);
+ ResponseEntity> actual = withdrawalService.getAllWithdrawalsFromAccountId(testWithdrawal.getId());
+ Assert.assertEquals(expected, actual);
+ }
+ @Test
+ public void getWithdrawalsByIdTest(){
+ when(withdrawalRepo.findOne(isA(Long.class))).thenReturn(testWithdrawal);
+ ResponseEntity expected = new ResponseEntity<>(testWithdrawal, HttpStatus.OK);
+ ResponseEntity actual = withdrawalService.getWithdrawalsByWithdrawalId(testWithdrawal.getId());
+ Assert.assertEquals(expected, actual);
+ verify(withdrawalRepo).findOne(isA(Long.class));
+ }
+ @Test
+ public void createWithdrawalTest(){
+ when(withdrawalRepo.findOne(1L)).thenReturn(testWithdrawal);
+ when(withdrawalRepo.save(isA(Withdrawal.class))).thenReturn(testWithdrawal);
+ ResponseEntity expected = new ResponseEntity<>(testWithdrawal, HttpStatus.CREATED);
+ ResponseEntity actual = withdrawalService.createWithdrawal(testWithdrawal.getId(), testWithdrawal);
+ Assert.assertEquals(expected, actual);
+ }
+ @Test
+ public void updateWithdrawalTest(){
+ when(withdrawalRepo.save(isA(Withdrawal.class))).thenReturn(testWithdrawal);
+ ResponseEntity expected = new ResponseEntity<>(testWithdrawal, HttpStatus.OK);
+ ResponseEntity actual = withdrawalService.updateWithdrawal(testWithdrawal.getId(), testWithdrawal);
+ Assert.assertEquals(expected, actual);
+ }
+ @Test
+ public void deleteWithdrawalTest(){
+ ResponseEntity expected = new ResponseEntity(HttpStatus.OK);
+ ResponseEntity actual = withdrawalService.deleteWithdrawal(testWithdrawal.getId());
+ verify(withdrawalRepo).delete(isA(Long.class));
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/zipperbankUML.png b/zipperbankUML.png
new file mode 100644
index 0000000..ad51f00
Binary files /dev/null and b/zipperbankUML.png differ