feat: Database model & configuration
This commit is contained in:
parent
c087081d25
commit
ee6c6eda02
10 changed files with 209 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
|||
package eu.ztsh.wymiana.data.repository;
|
||||
|
||||
import eu.ztsh.wymiana.data.entity.CurrencyEntity;
|
||||
import eu.ztsh.wymiana.data.entity.UserEntity;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest
|
||||
@ExtendWith(SpringExtension.class)
|
||||
class UserRepositoryTest {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
UserRepositoryTest(UserRepository userRepository) {
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void prepareTest() {
|
||||
userRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@DisplayName("Basic insert & get test")
|
||||
void basicTest() {
|
||||
var pesel = "00281018264";
|
||||
var entity = new UserEntity(pesel, "Janina", "Kowalska",
|
||||
List.of(new CurrencyEntity(pesel, "PLN", 20.10)));
|
||||
userRepository.save(entity);
|
||||
assertThat(userRepository.findById(pesel))
|
||||
.isNotEmpty()
|
||||
.get()
|
||||
.usingRecursiveComparison()
|
||||
.isEqualTo(entity);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue