Hendrik Jungnitsch
2023-09-19 bf5289fe36df7633f8d7bade10fd4f0c993c31c6
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
package de.gedoplan.seminar.jpa.exercise;
 
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
 
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
 
@TestMethodOrder(MethodOrderer.MethodName.class)
@AutoConfigureMockMvc
@SpringBootTest
public class Exercise03Test {
    
    @Autowired
    MockMvc mockMvc;
 
    @Test
    void test01_findByOrigin() throws Exception {
        mockMvc.perform(get("/highways/findByOrigin/{origin}", "Dortmund"))
        .andExpect(jsonPath("$.size()",is(2)));
    }
    
    @Test
    void test02_countOrigins() throws Exception {
        mockMvc.perform(get("/highways/countOrigins"))
        .andExpect(jsonPath("$",is(2)));
    }
}