NOTICKET: Update TestData Generation
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
parent
5c06b052af
commit
ebabb3f03d
2 changed files with 63 additions and 68 deletions
|
@ -3,7 +3,6 @@ package de.hmmh.pmt;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.hmmh.pmt.db.Project;
|
import de.hmmh.pmt.db.Project;
|
||||||
import de.hmmh.pmt.db.ProjectRepository;
|
import de.hmmh.pmt.db.ProjectRepository;
|
||||||
import de.hmmh.pmt.employee.ApiClientFactory;
|
|
||||||
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
|
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
|
||||||
import de.hmmh.pmt.employee.api.QualificationControllerApi;
|
import de.hmmh.pmt.employee.api.QualificationControllerApi;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -16,7 +15,8 @@ import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc(addFilters = false)
|
@AutoConfigureMockMvc(addFilters = false)
|
||||||
|
@ -47,70 +47,65 @@ public abstract class IntegrationTest {
|
||||||
projectRepository.deleteAll();
|
projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Project> createTestProjectData() {
|
protected Map<String, Project> createTestProjectData() {
|
||||||
Project project1 = new Project(
|
Map<String, Project> projects = new HashMap<>();
|
||||||
1L,
|
|
||||||
"Build a Dream Space Station",
|
Project researchLabProject = new Project();
|
||||||
"Launch a self-sustaining space habitat!",
|
researchLabProject.setName("Underwater Research Lab");
|
||||||
42L,
|
researchLabProject.setGoal( "Discover new marine species!");
|
||||||
101L,
|
researchLabProject.setCustomerId(73L);
|
||||||
LocalDateTime.of(2024, 3, 1, 10, 0),
|
researchLabProject.setAdministratorId(202L);
|
||||||
LocalDateTime.of(2028, 6, 30, 18, 0),
|
researchLabProject.setStart(LocalDateTime.of(2025, 5, 22, 8, 45));
|
||||||
LocalDateTime.of(2029, 12, 15, 16, 30)
|
researchLabProject.setPlannedEnd(LocalDateTime.of(2026, 5, 22, 8, 45));
|
||||||
);
|
projects.put("research-lab", researchLabProject);
|
||||||
Project project2 = new Project(
|
|
||||||
2L,
|
Project spaceStationProject = new Project();
|
||||||
"Underwater Research Lab",
|
spaceStationProject.setName("International Space Station Expansion");
|
||||||
"Discover new marine species!",
|
spaceStationProject.setGoal("Build new modules for extended research.");
|
||||||
73L,
|
spaceStationProject.setCustomerId(85L);
|
||||||
202L,
|
spaceStationProject.setAdministratorId(150L);
|
||||||
LocalDateTime.of(2025, 5, 22, 8, 45),
|
spaceStationProject.setStart(LocalDateTime.of(2024, 10, 15, 10, 0));
|
||||||
LocalDateTime.of(2027, 11, 5, 17, 0),
|
spaceStationProject.setPlannedEnd(LocalDateTime.of(2025, 12, 15, 10, 0));
|
||||||
LocalDateTime.of(2027, 10, 20, 14, 0)
|
projects.put("space-station", spaceStationProject);
|
||||||
);
|
|
||||||
Project project3 = new Project(
|
Project aiResearchProject = new Project();
|
||||||
3L,
|
aiResearchProject.setName("AI Human Interaction Study");
|
||||||
"AI-Powered Smart City",
|
aiResearchProject.setGoal("Study AI interactions in healthcare.");
|
||||||
"Create the world's most advanced smart city!",
|
aiResearchProject.setCustomerId(63L);
|
||||||
89L,
|
aiResearchProject.setAdministratorId(180L);
|
||||||
303L,
|
aiResearchProject.setStart(LocalDateTime.of(2023, 11, 3, 9, 30));
|
||||||
LocalDateTime.of(2026, 9, 14, 12, 0),
|
aiResearchProject.setPlannedEnd(LocalDateTime.of(2024, 6, 3, 9, 30));
|
||||||
LocalDateTime.of(2030, 4, 1, 9, 30),
|
projects.put("ai-research", aiResearchProject);
|
||||||
LocalDateTime.of(2030, 5, 2, 15, 0)
|
|
||||||
);
|
Project renewableEnergyProject = new Project();
|
||||||
Project project4 = new Project(
|
renewableEnergyProject.setName("Renewable Energy Storage System");
|
||||||
4L,
|
renewableEnergyProject.setGoal("Develop new battery tech for solar power.");
|
||||||
"Renewable Energy Revolution",
|
renewableEnergyProject.setCustomerId(90L);
|
||||||
"Replace all fossil fuels with renewables!",
|
renewableEnergyProject.setAdministratorId(175L);
|
||||||
56L,
|
renewableEnergyProject.setStart(LocalDateTime.of(2024, 1, 10, 11, 0));
|
||||||
404L,
|
renewableEnergyProject.setPlannedEnd(LocalDateTime.of(2025, 1, 10, 11, 0));
|
||||||
LocalDateTime.of(2023, 7, 19, 11, 30),
|
projects.put("renewable-energy", renewableEnergyProject);
|
||||||
LocalDateTime.of(2029, 12, 31, 20, 0),
|
|
||||||
LocalDateTime.of(2029, 10, 5, 18, 45)
|
Project climateChangeProject = new Project();
|
||||||
);
|
climateChangeProject.setName("Climate Change Impact Analysis");
|
||||||
Project project5 = new Project(
|
climateChangeProject.setGoal("Study global warming effects on ecosystems.");
|
||||||
5L,
|
climateChangeProject.setCustomerId(72L);
|
||||||
"Virtual Reality Theme Park",
|
climateChangeProject.setAdministratorId(190L);
|
||||||
"Build a fully immersive VR theme park!",
|
climateChangeProject.setStart(LocalDateTime.of(2025, 3, 12, 8, 0));
|
||||||
99L,
|
climateChangeProject.setPlannedEnd(LocalDateTime.of(2026, 3, 12, 8, 0));
|
||||||
505L,
|
projects.put("climate change", climateChangeProject);
|
||||||
LocalDateTime.of(2024, 2, 28, 9, 15),
|
|
||||||
LocalDateTime.of(2026, 9, 30, 17, 0),
|
|
||||||
LocalDateTime.of(2026, 8, 15, 13, 45)
|
Project medicalResearchProject = new Project();
|
||||||
);
|
medicalResearchProject.setName("Cancer Treatment Innovation");
|
||||||
|
medicalResearchProject.setGoal("Develop new gene therapy techniques.");
|
||||||
|
medicalResearchProject.setCustomerId(95L);
|
||||||
|
medicalResearchProject.setAdministratorId(155L);
|
||||||
|
medicalResearchProject.setStart(LocalDateTime.of(2024, 8, 20, 9, 15));
|
||||||
|
medicalResearchProject.setPlannedEnd(LocalDateTime.of(2026, 8, 20, 9, 15));
|
||||||
|
projects.put("medical-research", medicalResearchProject);
|
||||||
|
|
||||||
projectRepository.save(project1);
|
projectRepository.saveAllAndFlush(projects.values());
|
||||||
projectRepository.save(project2);
|
return projects;
|
||||||
projectRepository.save(project3);
|
|
||||||
projectRepository.save(project4);
|
|
||||||
projectRepository.save(project5);
|
|
||||||
|
|
||||||
return List.of(
|
|
||||||
project1,
|
|
||||||
project2,
|
|
||||||
project3,
|
|
||||||
project4,
|
|
||||||
project5
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import de.hmmh.pmt.IntegrationTest;
|
||||||
import de.hmmh.pmt.db.Project;
|
import de.hmmh.pmt.db.Project;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.empty;
|
import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
@ -25,7 +25,7 @@ public class GetAllTest extends IntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void multipleProjects() throws Exception {
|
void multipleProjects() throws Exception {
|
||||||
List<Project> allProjects = createTestProjectData();
|
Map<String, Project> allProjects = createTestProjectData();
|
||||||
|
|
||||||
mvc
|
mvc
|
||||||
.perform(get(baseUri + "/project"))
|
.perform(get(baseUri + "/project"))
|
||||||
|
|
Loading…
Reference in a new issue