File tree Expand file tree Collapse file tree 3 files changed +47
-5
lines changed
src/test/java/com/getourguide/interview Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1
1
package com .getourguide .interview ;
2
2
3
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
4
+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
5
+
3
6
import org .junit .jupiter .api .Test ;
7
+ import org .springframework .beans .factory .annotation .Autowired ;
8
+ import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
4
9
import org .springframework .boot .test .context .SpringBootTest ;
10
+ import org .springframework .test .web .servlet .MockMvc ;
5
11
6
12
@ SpringBootTest
13
+ @ AutoConfigureMockMvc
7
14
class GetYourGuideApplicationTests {
15
+ @ Autowired
16
+ private MockMvc mockMvc ;
8
17
9
18
@ Test
10
- void contextLoads () {
19
+ void contextLoads () throws Exception {
20
+ mockMvc .perform (get ("/activities" ))
21
+ .andExpect (status ().isOk ());
11
22
}
12
-
13
23
}
Original file line number Diff line number Diff line change
1
+ package com .getourguide .interview .controller ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .*;
4
+
5
+ import org .junit .jupiter .api .Test ;
6
+ import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .boot .test .context .SpringBootTest ;
8
+
9
+ @ SpringBootTest
10
+ class ActivitiesControllerTest {
11
+ @ Autowired
12
+ private ActivitiesController activitiesController ;
13
+
14
+ @ Test
15
+ void testGetActivities () {
16
+ var result = activitiesController .activities ();
17
+ assertNotNull (result );
18
+ }
19
+ }
Original file line number Diff line number Diff line change 1
1
package com .getourguide .interview .service ;
2
2
3
- import static org .junit .jupiter .api .Assertions .*;
4
-
5
3
import com .getourguide .interview .controller .SupplierController ;
6
4
import com .getourguide .interview .repository .ActivityRepository ;
5
+ import java .util .List ;
6
+ import org .junit .jupiter .api .Assertions ;
7
7
import org .junit .jupiter .api .BeforeEach ;
8
8
import org .junit .jupiter .api .Test ;
9
9
@@ -24,6 +24,19 @@ void setup() {
24
24
}
25
25
26
26
@ Test
27
- void test () {
27
+ void testGetActivities () {
28
+ var testActivity = createActivity (
29
+ 1L ,
30
+ "Test Activity" ,
31
+ 100 ,
32
+ 5.0 ,
33
+ false ,
34
+ createSupplier (1L , "Test Supplier" )
35
+ );
36
+ when (activityRepository .findAll ()).thenReturn (List .of (testActivity ));
37
+
38
+ var result = activityService .getActivities ();
39
+
40
+ Assertions .assertNotNull (result );
28
41
}
29
42
}
You can’t perform that action at this time.
0 commit comments