1
1
package org .example .data ;
2
2
3
+ import org .example .domain .Person ;
3
4
import org .junit .Test ;
4
5
import org .junit .runner .RunWith ;
5
6
import org .springframework .beans .factory .annotation .Autowired ;
6
7
import org .springframework .boot .test .context .SpringBootTest ;
7
8
import org .springframework .test .context .junit4 .SpringRunner ;
8
9
9
- import static org .junit .Assert .assertNotNull ;
10
+ import java .util .List ;
11
+ import java .util .UUID ;
12
+
13
+ import static org .junit .Assert .*;
10
14
11
15
@ RunWith (SpringRunner .class )
12
16
@ SpringBootTest
@@ -15,6 +19,31 @@ public class PersonRepositoryTests
15
19
@ Autowired
16
20
private PersonRepository repository ;
17
21
22
+ @ Test
23
+ public void testFindByFirstName ()
24
+ {
25
+ final String firstName = UUID .randomUUID ().toString (), lastName = "001:1" ;
26
+
27
+ final Person person = new Person ();
28
+ person .setFirstName (firstName );
29
+ person .setLastName (lastName );
30
+
31
+ repository .save (person );
32
+
33
+ final List <Person > results = repository .findByFirstName (firstName );
34
+
35
+ assertNotNull (results );
36
+ assertFalse (results .isEmpty ());
37
+
38
+ results .forEach (person1 -> {
39
+ assertNotNull (person );
40
+ assertNotNull (person .getFirstName ());
41
+ assertNotNull (person .getLastName ());
42
+ assertEquals (firstName , person .getFirstName ());
43
+ assertEquals (lastName , person .getLastName ());
44
+ });
45
+ }
46
+
18
47
@ Test
19
48
public void testFindByFirstNameAndLastName ()
20
49
{
0 commit comments