PMT-32: testing with testData
Some checks failed
Quality Check / Validate OAS (push) Successful in 30s
Quality Check / Testing (push) Failing after 29s
Quality Check / Linting (push) Successful in 56s
Quality Check / Static Analysis (push) Successful in 1m1s

This commit is contained in:
Ole Kück 2024-10-01 13:39:46 +02:00
parent 7a1cd15552
commit a3fcc42d7a

View file

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