File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/test/java/guru/springframework/sfgpetclinic/services/springdatajpa Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 88import org .mockito .Mock ;
99import org .mockito .junit .jupiter .MockitoExtension ;
1010
11+ import java .util .Optional ;
12+
13+ import static org .assertj .core .api .Assertions .assertThat ;
1114import static org .junit .jupiter .api .Assertions .*;
1215import static org .mockito .Mockito .*;
1316
@@ -20,6 +23,22 @@ class SpecialitySDJpaServiceTest {
2023 @ InjectMocks
2124 SpecialitySDJpaService service ;
2225
26+ @ Test
27+ void findByIdTest (){
28+ Speciality speciality = new Speciality ();
29+
30+ when (specialtyRepository .findById (1L )).thenReturn (Optional .of (speciality ));
31+
32+ Speciality foundSpeciality = service .findById (1L );
33+
34+ assertThat (foundSpeciality ).isNotNull ();
35+
36+ verify (specialtyRepository ).findById (1L );
37+
38+ System .out .println ("speciality = " + speciality );
39+ System .out .println ("foundSpeciality = " + foundSpeciality );
40+ }
41+
2342 @ Test
2443 void deleteById () {
2544 service .deleteById (1L );
You can’t perform that action at this time.
0 commit comments