Hendrik Jungnitsch
2023-09-18 be053d7d5140b267dfc252d1c82161b6f9a593ca
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
35
package de.gedoplan.seminar.sbt.di.exercise;
 
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.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
@AutoConfigureMockMvc
@SpringBootTest
public class Exercise10Test {
 
    @Autowired
    MockMvc mockMvc;
 
    @Test
    public void test() throws Exception {
        String location = mockMvc.perform(post("/api/mixer/order"))
                .andExpect(status().isCreated())
                .andReturn().getResponse().getHeader("Location");
 
        mockMvc.perform(post(location+"/kirr"))
                .andExpect(status().isCreated());
 
        mockMvc.perform(post(location+"/stdq"))
                .andExpect(status().isConflict());
 
        mockMvc.perform(put(location+"/placed"))
                .andExpect(status().isNoContent());
    }
}