PMT-32: testing
This commit is contained in:
parent
5db4d4dab8
commit
7481b48b9f
3 changed files with 31 additions and 5 deletions
|
@ -45,4 +45,6 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/GetAllProjectsDTO"
|
$ref: "#/components/schemas/GetAllProjectsDTO"
|
||||||
|
500:
|
||||||
|
$ref: "#/components/responses/InternalError"
|
|
@ -8,6 +8,8 @@ import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
import de.hmmh.pmt.db.ProjectRepository;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
|
@ -15,12 +17,12 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||||
public abstract class IntegrationTest {
|
public abstract class IntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected MockMvc mockMvc;
|
protected MockMvc mvc;
|
||||||
|
@Autowired
|
||||||
//protected Repository repository;
|
protected ProjectRepository projectRepository;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
//repository.deleteAll();
|
projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
src/test/java/de/hmmh/pmt/project/GetAllTest.java
Normal file
22
src/test/java/de/hmmh/pmt/project/GetAllTest.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package de.hmmh.pmt.project;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
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;
|
||||||
|
import static org.hamcrest.Matchers.empty;
|
||||||
|
|
||||||
|
import de.hmmh.pmt.IntegrationTest;
|
||||||
|
|
||||||
|
public class GetAllTest extends IntegrationTest {
|
||||||
|
@Test
|
||||||
|
void emptyList()throws Exception{
|
||||||
|
assert projectRepository.findAll().isEmpty();
|
||||||
|
mvc
|
||||||
|
.perform(get("/project"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$", empty()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue