Hendrik Jungnitsch
2022-09-19 079b31c63de76f15ae905187a7f2e02e1e32e73c
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
package de.gedoplan.seminar.sbt.sbtrestexercise;
 
import org.junit.jupiter.api.Test;
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;
 
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
 
@SpringBootTest
@AutoConfigureMockMvc
public class Exercise01Test {
 
    @Autowired
    private MockMvc mockMvc;
 
    @Test
    public void testGetAll() throws Exception {
        mockMvc.perform(get("/personen"))
                .andExpect(jsonPath("$.size()").value(2));
    }
 
    @Test
    public void testGetById() throws Exception {
        mockMvc.perform(get("/personen/{id}",2))
                .andExpect(jsonPath("$.name").value("Musterfrau"));
    }
}