Hendrik Jungnitsch
2022-09-07 18134907066301a801f4747926592c5977141279
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
package de.gedoplan.seminar.jpa.exercise;
 
import static org.hamcrest.CoreMatchers.hasItems;
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 Exercise06Test {
    
    @Autowired
    MockMvc mockMvc;
    
    @Test
    public void test01_findByHighwayId() throws Exception {
        mockMvc.perform(get("/mdeps/findByHighwayName").param("name", "A2"))
            .andExpect(jsonPath("$.size()", is(2)))
            .andExpect(jsonPath("$[*].name", hasItems("Kamen", "Bielefeld")));
    }
    
}