diff --git a/api/pmt.yml b/api/pmt.yml index 159e6a5..b498fc0 100644 --- a/api/pmt.yml +++ b/api/pmt.yml @@ -45,4 +45,6 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/GetAllProjectsDTO" \ No newline at end of file + $ref: "#/components/schemas/GetAllProjectsDTO" + 500: + $ref: "#/components/responses/InternalError" \ No newline at end of file diff --git a/src/test/java/de/hmmh/pmt/IntegrationTest.java b/src/test/java/de/hmmh/pmt/IntegrationTest.java index 6df5bcc..f7a2224 100644 --- a/src/test/java/de/hmmh/pmt/IntegrationTest.java +++ b/src/test/java/de/hmmh/pmt/IntegrationTest.java @@ -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(); } } diff --git a/src/test/java/de/hmmh/pmt/project/GetAllTest.java b/src/test/java/de/hmmh/pmt/project/GetAllTest.java new file mode 100644 index 0000000..5701e06 --- /dev/null +++ b/src/test/java/de/hmmh/pmt/project/GetAllTest.java @@ -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())); + + } + +}