diff --git a/src/test/java/de/hmmh/pmt/project/GetAllTest.java b/src/test/java/de/hmmh/pmt/project/GetAllTest.java index 849831c..cce91ff 100644 --- a/src/test/java/de/hmmh/pmt/project/GetAllTest.java +++ b/src/test/java/de/hmmh/pmt/project/GetAllTest.java @@ -1,16 +1,23 @@ package de.hmmh.pmt.project; import de.hmmh.pmt.IntegrationTest; +import de.hmmh.pmt.db.Project; +import java.time.LocalDateTime; +import java.time.LocalDate; +import java.time.LocalTime; + + import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasSize; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; public class GetAllTest extends IntegrationTest { @Test - void emptyList() throws Exception { + void noProjects() throws Exception { assert projectRepository.findAll().isEmpty(); mvc .perform(get(baseUri + "/project")) @@ -18,4 +25,46 @@ public class GetAllTest extends IntegrationTest { .andExpect(jsonPath("$", empty())); } + @Test + void multipleProjects() throws Exception { + Project testProjekt1 = new Project( + 0L, + "testName1", + "testGoaaaaaaaal!", + 0L, + 0L, + LocalDateTime.of(2001, 9, 11, 13, 34), + LocalDateTime.of(2002, 8, 13, 14, 34), + LocalDateTime.of(2003, 7, 12, 23, 34) + ); + Project testProjekt2 = new Project( + 0L, + "testName2", + "testGoaaaaaaaal!", + 0L, + 0L, + LocalDateTime.of(2009, 9, 11, 13, 34), + LocalDateTime.of(2009, 12, 13, 14, 34), + LocalDateTime.of(2010, 7, 12, 23, 34) + ); + Project testProjekt3 = new Project( + 0L, + "testName3", + "testGoaaaaaaaal!", + 0L, + 0L, + LocalDateTime.of(2010, 9, 11, 13, 34), + LocalDateTime.of(2012, 8, 13, 14, 34), + LocalDateTime.of(2013, 7, 12, 23, 34) + ); + projectRepository.save(testProjekt1); + projectRepository.save(testProjekt2); + projectRepository.save(testProjekt3); + + mvc + .perform(get(baseUri + "/project")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", hasSize(3))); + } + }