Compare commits
14 commits
fcf1371891
...
bd8f92a9c6
Author | SHA1 | Date | |
---|---|---|---|
|
bd8f92a9c6 | ||
7913300fa3 | |||
280f22aa87 | |||
4cd4788010 | |||
fe39ea30f6 | |||
|
33cd8dae39 | ||
af3b3108e9 | |||
|
4a8eebc650 | ||
c02d95a12d | |||
99fdf967dc | |||
ed5c58ec6f | |||
34f2462984 | |||
a69fdfdda5 | |||
b936136b53 |
7 changed files with 89 additions and 127 deletions
|
@ -1,12 +1,24 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Test" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Test" type="GradleRunConfiguration" factoryName="Gradle">
|
||||||
<module name="Project_Management_Tool.test" />
|
<ExternalSystemSettings>
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="executionName" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="externalSystemIdString" value="GRADLE" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="scriptParameters" value="" />
|
||||||
<method v="2">
|
<option name="taskDescriptions">
|
||||||
<option name="Make" enabled="true" />
|
<list />
|
||||||
</method>
|
</option>
|
||||||
|
<option name="taskNames">
|
||||||
|
<list>
|
||||||
|
<option value="test" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="vmOptions" />
|
||||||
|
</ExternalSystemSettings>
|
||||||
|
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||||
|
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||||
|
<DebugAllEnabled>false</DebugAllEnabled>
|
||||||
|
<RunAsTest>false</RunAsTest>
|
||||||
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
|
@ -144,8 +144,6 @@ paths:
|
||||||
$ref: "#/components/responses/InternalError"
|
$ref: "#/components/responses/InternalError"
|
||||||
503:
|
503:
|
||||||
$ref: "#/components/responses/ServiceUnavailable"
|
$ref: "#/components/responses/ServiceUnavailable"
|
||||||
|
|
||||||
|
|
||||||
/project/{id}:
|
/project/{id}:
|
||||||
delete:
|
delete:
|
||||||
operationId: "deleteProject"
|
operationId: "deleteProject"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"invokerPackage": "de.hmmh.pmt",
|
"invokerPackage": "de.hmmh.pmt",
|
||||||
"java8": false,
|
"java8": false,
|
||||||
"java11": true,
|
"java11": true,
|
||||||
"dateLibrary": "java8-localdatetime",
|
"dateLibrary": "java11",
|
||||||
"library": "spring-boot3",
|
"library": "spring-boot3",
|
||||||
"defaultInterfaces": false,
|
"defaultInterfaces": false,
|
||||||
"serializableModel": true
|
"serializableModel": true
|
||||||
|
|
|
@ -41,16 +41,6 @@ public class ApiController implements DefaultApi {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<Void> deleteProject(Long id) {
|
|
||||||
if (!projectRepository.existsById(id)) {
|
|
||||||
return ResponseEntity.notFound().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
projectRepository.deleteById(id);
|
|
||||||
return ResponseEntity.noContent().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<GetAllProjectsDTO> getAllProjects() {
|
public ResponseEntity<GetAllProjectsDTO> getAllProjects() {
|
||||||
GetAllProjectsDTO response = new GetAllProjectsDTO();
|
GetAllProjectsDTO response = new GetAllProjectsDTO();
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
package de.hmmh.pmt;
|
package de.hmmh.pmt;
|
||||||
|
|
||||||
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.api.EmployeeControllerApi;
|
|
||||||
import de.hmmh.pmt.employee.api.QualificationControllerApi;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
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.HashMap;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc(addFilters = false)
|
@AutoConfigureMockMvc(addFilters = false)
|
||||||
|
@ -28,15 +23,8 @@ public abstract class IntegrationTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
protected MockMvc mvc;
|
protected MockMvc mvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ObjectMapper objectMapper;
|
|
||||||
@Autowired
|
|
||||||
protected ProjectRepository projectRepository;
|
protected ProjectRepository projectRepository;
|
||||||
|
|
||||||
@MockBean
|
|
||||||
protected EmployeeControllerApi mockEmployeeApi;
|
|
||||||
@MockBean
|
|
||||||
protected QualificationControllerApi mockQualificationApi;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
projectRepository.deleteAll();
|
projectRepository.deleteAll();
|
||||||
|
@ -47,65 +35,70 @@ public abstract class IntegrationTest {
|
||||||
projectRepository.deleteAll();
|
projectRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Project> createTestProjectData() {
|
protected List<Project> createTestProjectData() {
|
||||||
Map<String, Project> projects = new HashMap<>();
|
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 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 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)
|
||||||
|
);
|
||||||
|
|
||||||
Project researchLabProject = new Project();
|
projectRepository.save(project1);
|
||||||
researchLabProject.setName("Underwater Research Lab");
|
projectRepository.save(project2);
|
||||||
researchLabProject.setGoal( "Discover new marine species!");
|
projectRepository.save(project3);
|
||||||
researchLabProject.setCustomerId(73L);
|
projectRepository.save(project4);
|
||||||
researchLabProject.setAdministratorId(202L);
|
projectRepository.save(project5);
|
||||||
researchLabProject.setStart(LocalDateTime.of(2025, 5, 22, 8, 45));
|
|
||||||
researchLabProject.setPlannedEnd(LocalDateTime.of(2026, 5, 22, 8, 45));
|
|
||||||
projects.put("research-lab", researchLabProject);
|
|
||||||
|
|
||||||
Project spaceStationProject = new Project();
|
return List.of(
|
||||||
spaceStationProject.setName("International Space Station Expansion");
|
project1,
|
||||||
spaceStationProject.setGoal("Build new modules for extended research.");
|
project2,
|
||||||
spaceStationProject.setCustomerId(85L);
|
project3,
|
||||||
spaceStationProject.setAdministratorId(150L);
|
project4,
|
||||||
spaceStationProject.setStart(LocalDateTime.of(2024, 10, 15, 10, 0));
|
project5
|
||||||
spaceStationProject.setPlannedEnd(LocalDateTime.of(2025, 12, 15, 10, 0));
|
);
|
||||||
projects.put("space-station", spaceStationProject);
|
|
||||||
|
|
||||||
Project aiResearchProject = new Project();
|
|
||||||
aiResearchProject.setName("AI Human Interaction Study");
|
|
||||||
aiResearchProject.setGoal("Study AI interactions in healthcare.");
|
|
||||||
aiResearchProject.setCustomerId(63L);
|
|
||||||
aiResearchProject.setAdministratorId(180L);
|
|
||||||
aiResearchProject.setStart(LocalDateTime.of(2023, 11, 3, 9, 30));
|
|
||||||
aiResearchProject.setPlannedEnd(LocalDateTime.of(2024, 6, 3, 9, 30));
|
|
||||||
projects.put("ai-research", aiResearchProject);
|
|
||||||
|
|
||||||
Project renewableEnergyProject = new Project();
|
|
||||||
renewableEnergyProject.setName("Renewable Energy Storage System");
|
|
||||||
renewableEnergyProject.setGoal("Develop new battery tech for solar power.");
|
|
||||||
renewableEnergyProject.setCustomerId(90L);
|
|
||||||
renewableEnergyProject.setAdministratorId(175L);
|
|
||||||
renewableEnergyProject.setStart(LocalDateTime.of(2024, 1, 10, 11, 0));
|
|
||||||
renewableEnergyProject.setPlannedEnd(LocalDateTime.of(2025, 1, 10, 11, 0));
|
|
||||||
projects.put("renewable-energy", renewableEnergyProject);
|
|
||||||
|
|
||||||
Project climateChangeProject = new Project();
|
|
||||||
climateChangeProject.setName("Climate Change Impact Analysis");
|
|
||||||
climateChangeProject.setGoal("Study global warming effects on ecosystems.");
|
|
||||||
climateChangeProject.setCustomerId(72L);
|
|
||||||
climateChangeProject.setAdministratorId(190L);
|
|
||||||
climateChangeProject.setStart(LocalDateTime.of(2025, 3, 12, 8, 0));
|
|
||||||
climateChangeProject.setPlannedEnd(LocalDateTime.of(2026, 3, 12, 8, 0));
|
|
||||||
projects.put("climate change", climateChangeProject);
|
|
||||||
|
|
||||||
|
|
||||||
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.saveAllAndFlush(projects.values());
|
|
||||||
return projects;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
package de.hmmh.pmt.project;
|
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import de.hmmh.pmt.IntegrationTest;
|
|
||||||
import de.hmmh.pmt.db.Project;
|
|
||||||
|
|
||||||
public class DeleteTest extends IntegrationTest {
|
|
||||||
@Test
|
|
||||||
void projectNotFound() throws Exception {
|
|
||||||
mvc
|
|
||||||
.perform(delete(baseUri + "/project/1"))
|
|
||||||
.andExpect(status().isNotFound())
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void deletedSuccessfully() throws Exception {
|
|
||||||
Map<String,Project> allProjects = createTestProjectData();
|
|
||||||
mvc
|
|
||||||
.perform(delete(baseUri + "/project/" + allProjects.get("space-station").getId()))
|
|
||||||
.andExpect(status().isNoContent())
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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.Map;
|
import java.util.List;
|
||||||
|
|
||||||
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 {
|
||||||
Map<String, Project> allProjects = createTestProjectData();
|
List<Project> allProjects = createTestProjectData();
|
||||||
|
|
||||||
mvc
|
mvc
|
||||||
.perform(get(baseUri + "/project"))
|
.perform(get(baseUri + "/project"))
|
||||||
|
|
Loading…
Reference in a new issue