File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/test/java/guru/springframework/sfgpetclinic/services/springdatajpa Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1212
1313import static org .assertj .core .api .Assertions .assertThat ;
1414import static org .junit .jupiter .api .Assertions .*;
15+ import static org .mockito .BDDMockito .given ;
1516import static org .mockito .Mockito .*;
1617
1718@ ExtendWith (MockitoExtension .class )
@@ -47,6 +48,17 @@ void findByIdTest(){
4748 System .out .println ("foundSpeciality = " + foundSpeciality );
4849 }
4950
51+ @ Test
52+ void findByIdBddTest () {
53+ Speciality speciality = new Speciality ();
54+
55+ given (specialtyRepository .findById (1L )).willReturn (Optional .of (speciality ));
56+
57+ Speciality foundSpeciality = service .findById (1L );
58+ assertThat (foundSpeciality ).isNotNull ();
59+ verify (specialtyRepository ).findById (anyLong ());
60+ }
61+
5062 @ Test
5163 void deleteById () {
5264 service .deleteById (1L );
You can’t perform that action at this time.
0 commit comments