mirror of
https://github.com/Prominence/car-repair-site.git
synced 2026-01-08 11:16:49 +03:00
Added simple integration test.
This commit is contained in:
parent
a0df8027e6
commit
463113b161
6
pom.xml
6
pom.xml
@ -77,6 +77,12 @@
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
<version>1.3.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>1.4.199</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package com.github.prominence.carrepair;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CarRepairApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.github.prominence.carrepair;
|
||||
|
||||
import com.github.prominence.carrepair.model.domain.Client;
|
||||
import com.github.prominence.carrepair.repository.ClientRepository;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest
|
||||
public class ClientRepositoryIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
private ClientRepository clientRepository;
|
||||
|
||||
@Test
|
||||
public void whenFindById_thenReturnClient() {
|
||||
// given
|
||||
Client client = new Client("firstName", "middleName", "lastName", "123456789");
|
||||
entityManager.persist(client);
|
||||
entityManager.flush();
|
||||
|
||||
// when
|
||||
Client found = clientRepository.findById(client.getId()).get();
|
||||
|
||||
// then
|
||||
assertThat(found.hashCode()).isEqualTo(client.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user