-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParentRepoTest.java
76 lines (62 loc) · 1.98 KB
/
ParentRepoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package io.github.cepr0.demo.repo;
import io.github.cepr0.demo.dto.ParentProjection;
import io.github.cepr0.demo.model.Parent;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Cepr0, 2018-01-30
*/
@ActiveProfiles("test")
@Transactional
@RunWith(SpringRunner.class)
@SpringBootTest
public class ParentRepoTest {
@Autowired private ParentRepo repo;
@Test
public void findAll() {
List<Parent> people = repo.findAll();
assertThat(people).hasSize(3);
}
@Test
public void findDistinctBy() {
List<Parent> people = repo.findDistinctBy();
assertThat(people).hasSize(3);
}
@Test // fails: Expected size:<3> but was:<4>
public void findWithQuery() {
List<Parent> people = repo.findWithQuery();
assertThat(people).hasSize(3);
}
@Test
public void findDistinctWithQuery() {
List<Parent> people = repo.findDistinctWithQuery();
assertThat(people).hasSize(3);
}
@Test // fails: Expected size:<2> but was:<4>
public void findProjectionsBy() {
List<ParentProjection> people = repo.findProjectionsBy();
assertThat(people).hasSize(3);
}
@Test
public void findDistinctProjectionsBy() {
List<ParentProjection> people = repo.findDistinctProjectionsBy();
assertThat(people).hasSize(3);
}
@Test // fails: Expected size:<3> but was:<4>
public void findProjectionsWithQuery() {
List<ParentProjection> people = repo.findProjectionsWithQuery();
assertThat(people).hasSize(3);
}
@Test // fails: Expected size:<3> but was:<4>
public void findDistinctProjectionsWithQuery() {
List<ParentProjection> people = repo.findDistinctProjectionsWithQuery();
assertThat(people).hasSize(3);
}
}