PMT-32: Add Test Data
This commit is contained in:
parent
34f2462984
commit
ed5c58ec6f
1 changed files with 69 additions and 38 deletions
|
@ -1,7 +1,7 @@
|
|||
package de.hmmh.pmt;
|
||||
|
||||
//import de.hmmh.pmt.db.Project;
|
||||
//import de.hmmh.pmt.db.ProjectRepository;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.db.ProjectRepository;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.test.context.ActiveProfiles;
|
|||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc(addFilters = false)
|
||||
|
@ -21,53 +22,83 @@ public abstract class IntegrationTest {
|
|||
|
||||
@Autowired
|
||||
protected MockMvc mvc;
|
||||
//@Autowired
|
||||
//protected ProjectRepository projectRepository;
|
||||
@Autowired
|
||||
protected ProjectRepository projectRepository;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
//projectRepository.deleteAll();
|
||||
projectRepository.deleteAll();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
//projectRepository.deleteAll();
|
||||
projectRepository.deleteAll();
|
||||
}
|
||||
|
||||
protected void createTestData() {
|
||||
/*Project testProject1 = 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)
|
||||
protected List<Project> createTestProjectData() {
|
||||
Project project1 = new Project(
|
||||
1L,
|
||||
"Build a Dream Space Station",
|
||||
"Launch a self-sustaining space habitat!",
|
||||
42L,
|
||||
101L,
|
||||
LocalDateTime.of(2024, 3, 1, 10, 0),
|
||||
LocalDateTime.of(2028, 6, 30, 18, 0),
|
||||
LocalDateTime.of(2029, 12, 15, 16, 30)
|
||||
);
|
||||
Project testProject2 = 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 project2 = new Project(
|
||||
2L,
|
||||
"Underwater Research Lab",
|
||||
"Discover new marine species!",
|
||||
73L,
|
||||
202L,
|
||||
LocalDateTime.of(2025, 5, 22, 8, 45),
|
||||
LocalDateTime.of(2027, 11, 5, 17, 0),
|
||||
LocalDateTime.of(2027, 10, 20, 14, 0)
|
||||
);
|
||||
Project testProject3 = 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)
|
||||
Project project3 = new Project(
|
||||
3L,
|
||||
"AI-Powered Smart City",
|
||||
"Create the world's most advanced smart city!",
|
||||
89L,
|
||||
303L,
|
||||
LocalDateTime.of(2026, 9, 14, 12, 0),
|
||||
LocalDateTime.of(2030, 4, 1, 9, 30),
|
||||
LocalDateTime.of(2030, 5, 2, 15, 0)
|
||||
);
|
||||
Project project4 = new Project(
|
||||
4L,
|
||||
"Renewable Energy Revolution",
|
||||
"Replace all fossil fuels with renewables!",
|
||||
56L,
|
||||
404L,
|
||||
LocalDateTime.of(2023, 7, 19, 11, 30),
|
||||
LocalDateTime.of(2029, 12, 31, 20, 0),
|
||||
LocalDateTime.of(2029, 10, 5, 18, 45)
|
||||
);
|
||||
Project project5 = new Project(
|
||||
5L,
|
||||
"Virtual Reality Theme Park",
|
||||
"Build a fully immersive VR theme park!",
|
||||
99L,
|
||||
505L,
|
||||
LocalDateTime.of(2024, 2, 28, 9, 15),
|
||||
LocalDateTime.of(2026, 9, 30, 17, 0),
|
||||
LocalDateTime.of(2026, 8, 15, 13, 45)
|
||||
);
|
||||
|
||||
projectRepository.save(project1);
|
||||
projectRepository.save(project2);
|
||||
projectRepository.save(project3);
|
||||
projectRepository.save(project4);
|
||||
projectRepository.save(project5);
|
||||
|
||||
return List.of(
|
||||
project1,
|
||||
project2,
|
||||
project3,
|
||||
project4,
|
||||
project5
|
||||
);
|
||||
projectRepository.save(testProject1);
|
||||
projectRepository.save(testProject2);
|
||||
projectRepository.save(testProject3);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue