Переключил хранение счетов на PostgreSQL и выделил конфигурацию памяти для тестов
This commit is contained in:
1 parent
c22f1f668f
commit
299acbe554
6 files changed
+42
-15
No files matched your search
@@ -50,10 +50,6 @@ public class Main {
|
|||||||
printAccountBalance(card, ledger);
|
printAccountBalance(card, ledger);
|
||||||
printAccountBalance(cash, ledger);
|
printAccountBalance(cash, ledger);
|
||||||
|
|
||||||
// operation5.removeLine(0);
|
|
||||||
// operationService.post(operation5);
|
|
||||||
// System.out.println("Удаление строк");
|
|
||||||
|
|
||||||
Operation operation6 = Operation.income(LocalDate.now(), 504L, card);
|
Operation operation6 = Operation.income(LocalDate.now(), 504L, card);
|
||||||
operationLine = new OperationLine(new Category(4L, "Salary"), new BigDecimal(20000));
|
operationLine = new OperationLine(new Category(4L, "Salary"), new BigDecimal(20000));
|
||||||
operation6.addLine(operationLine);
|
operation6.addLine(operationLine);
|
||||||
|
|||||||
@@ -20,18 +20,10 @@ public class AccountingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OperationService operationService(
|
public OperationService operationService(OperationJournal journal, Ledger ledger) {
|
||||||
OperationJournal journal,
|
|
||||||
Ledger ledger
|
|
||||||
) {
|
|
||||||
return new OperationService(journal, ledger);
|
return new OperationService(journal, ledger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AccountStore accountStore() {
|
|
||||||
return new InMemoryAccountStore();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AccountService accountService(AccountStore accountStore) {
|
public AccountService accountService(AccountStore accountStore) {
|
||||||
return new AccountService(accountStore);
|
return new AccountService(accountStore);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.sytes.kashey.easymoney.config;
|
||||||
|
|
||||||
|
import net.sytes.kashey.easymoney.persistence.AccountRepository;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.jdbc.core.simple.JdbcClient;
|
||||||
|
import service.AccountStore;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class PersistenceConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AccountStore accountStore(JdbcClient jdbcClient) {
|
||||||
|
return new AccountRepository(jdbcClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package net.sytes.kashey.easymoney.api;
|
|||||||
import model.Account;
|
import model.Account;
|
||||||
import model.Operation;
|
import model.Operation;
|
||||||
import net.sytes.kashey.easymoney.config.AccountingConfig;
|
import net.sytes.kashey.easymoney.config.AccountingConfig;
|
||||||
|
import net.sytes.kashey.easymoney.config.InMemoryStorageTestConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
||||||
@@ -29,7 +30,10 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
@WebMvcTest(AccountController.class)
|
@WebMvcTest(AccountController.class)
|
||||||
@Import(AccountingConfig.class)
|
@Import({
|
||||||
|
AccountingConfig.class,
|
||||||
|
InMemoryStorageTestConfig.class
|
||||||
|
})
|
||||||
class AccountControllerTest {
|
class AccountControllerTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.sytes.kashey.easymoney.api;
|
|||||||
import model.Account;
|
import model.Account;
|
||||||
import model.Operation;
|
import model.Operation;
|
||||||
import model.OperationType;
|
import model.OperationType;
|
||||||
|
import net.sytes.kashey.easymoney.config.InMemoryStorageTestConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||||
@@ -27,7 +28,10 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||||
|
|
||||||
@WebMvcTest(OperationController.class)
|
@WebMvcTest(OperationController.class)
|
||||||
@Import(AccountingConfig.class)
|
@Import({
|
||||||
|
AccountingConfig.class,
|
||||||
|
InMemoryStorageTestConfig.class
|
||||||
|
})
|
||||||
class OperationControllerTest {
|
class OperationControllerTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.sytes.kashey.easymoney.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.test.context.TestConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import service.AccountStore;
|
||||||
|
import service.InMemoryAccountStore;
|
||||||
|
|
||||||
|
@TestConfiguration
|
||||||
|
public class InMemoryStorageTestConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AccountStore accountStore() {
|
||||||
|
return new InMemoryAccountStore();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user