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"));
|
}
|
}
|