PMT-32: testing
Some checks failed
Quality Check / Validate OAS (push) Successful in 37s
Quality Check / Testing (push) Failing after 1m5s
Quality Check / Linting (push) Successful in 1m15s
Quality Check / Static Analysis (push) Successful in 1m20s

This commit is contained in:
Ole Kück 2024-09-30 16:24:36 +02:00
parent 5db4d4dab8
commit 7481b48b9f
3 changed files with 31 additions and 5 deletions

View file

@ -45,4 +45,6 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/GetAllProjectsDTO"
$ref: "#/components/schemas/GetAllProjectsDTO"
500:
$ref: "#/components/responses/InternalError"

View file

@ -8,6 +8,8 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import de.hmmh.pmt.db.ProjectRepository;
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
@ -15,12 +17,12 @@ import org.springframework.test.web.servlet.MockMvc;
public abstract class IntegrationTest {
@Autowired
protected MockMvc mockMvc;
//protected Repository repository;
protected MockMvc mvc;
@Autowired
protected ProjectRepository projectRepository;
@BeforeEach
void setUp() {
//repository.deleteAll();
projectRepository.deleteAll();
}
}

View 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()));
}
}