Compare commits

..

23 commits

Author SHA1 Message Date
Rajbir Singh
609cafcb71 added shouldNotCreateProjectWhenAdministratorDoesNotExist test
All checks were successful
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Successful in 1m7s
Quality Check / Static Analysis (push) Successful in 1m15s
Quality Check / Testing (push) Successful in 1m14s
Quality Check / Validate OAS (pull_request) Successful in 32s
Quality Check / Linting (pull_request) Successful in 1m9s
Quality Check / Testing (pull_request) Successful in 1m14s
Quality Check / Static Analysis (pull_request) Successful in 1m16s
2024-10-10 17:57:25 +02:00
Rajbir Singh
3e92e2747c added shouldNotCreateProjectWithSameName test 2024-10-10 17:09:45 +02:00
Rajbir Singh
beb293753b Merge remote-tracking branch 'origin/story/PMT-16-projekt-anlegen' into story/PMT-16-projekt-anlegen
# Conflicts:
#	api/pmt.yml
#	src/main/java/de/hmmh/pmt/ApiController.java
2024-10-10 14:16:44 +02:00
57de299b99
testing....... (Comit needs to be edited later)
All checks were successful
Quality Check / Validate OAS (push) Successful in 32s
Quality Check / Linting (push) Successful in 1m11s
Quality Check / Testing (push) Successful in 1m13s
Quality Check / Static Analysis (push) Successful in 1m16s
Co-authored-by: Rajbir Singh <rajbir.singh@hmmh.de>
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:26:37 +02:00
154c38c29f
PMT-16: Update Manual Validation Method of Projects to Include the builtin.
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:19:52 +02:00
0e5229520e
PMT-16: Implement New Endpoint Logic
Co-authored-by: Rajbir Singh <rajbir.singh@hmmh.de>
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:19:52 +02:00
d8bc3a5608
PMT-16: Add Validation for Time Range to Project Entity
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:19:52 +02:00
20492ecaef
PMT-16: Add Mapper for Project Creation/Created DTO to/from Project Entity
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:19:52 +02:00
Rajbir Singh
ec843eb946
PMT-16: Add Method to Check if Project with Name Exists to ProjectRepository 2024-10-10 11:19:52 +02:00
28c5f8bbf3
PMT-16: Add More Errors to Endpoint Specification
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-10 11:19:52 +02:00
Rajbir Singh
397e8dd529
PMT-16: Add Endpoint Specification 2024-10-10 11:19:52 +02:00
1b171cb085 Merge pull request 'PMT-15: Projekte löschen' (!11) from story/PMT-15-projekte-loeschen into trunk
All checks were successful
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Successful in 1m9s
Quality Check / Static Analysis (push) Successful in 1m15s
Quality Check / Testing (push) Successful in 1m13s
Reviewed-on: #11
2024-10-09 13:14:40 +00:00
2cf79e3568
PMT-15: Implement Tests for Responses
All checks were successful
Quality Check / Validate OAS (push) Successful in 48s
Quality Check / Validate OAS (pull_request) Successful in 1m6s
Quality Check / Linting (push) Successful in 2m4s
Quality Check / Linting (pull_request) Successful in 2m7s
Quality Check / Testing (push) Successful in 2m12s
Quality Check / Static Analysis (push) Successful in 2m22s
Quality Check / Testing (pull_request) Successful in 2m12s
Quality Check / Static Analysis (pull_request) Successful in 2m16s
2024-10-09 11:48:07 +02:00
d725addef8
PMT-15: added api documentation 2024-10-09 11:36:56 +02:00
165aee2ece
PMT-15: Added a deleteProject by ID method 2024-10-09 11:36:56 +02:00
e9e58b821e Merge pull request 'Fix Testing Setup' (!10) from bugfix/testing into trunk
All checks were successful
Quality Check / Validate OAS (push) Successful in 32s
Quality Check / Linting (push) Successful in 1m6s
Quality Check / Testing (push) Successful in 1m10s
Quality Check / Static Analysis (push) Successful in 1m14s
Reviewed-on: #10
Reviewed-by: SZUT-Ole <ole.kueck@hmmh.de>
2024-10-09 09:18:14 +00:00
ca7ad3f19d
NOTICKET: Revert Limiting to One Parallel run
All checks were successful
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m2s
Quality Check / Linting (push) Successful in 1m59s
Quality Check / Testing (push) Successful in 2m9s
Quality Check / Linting (pull_request) Successful in 2m7s
Quality Check / Static Analysis (push) Successful in 2m18s
Quality Check / Testing (pull_request) Successful in 2m8s
Quality Check / Static Analysis (pull_request) Successful in 2m12s
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:15:25 +02:00
d49d5233bf
NOTICKET: Update Intelij Run Config
All checks were successful
Quality Check / Validate OAS (push) Successful in 34s
Quality Check / Validate OAS (pull_request) Successful in 1m1s
Quality Check / Linting (push) Successful in 1m45s
Quality Check / Testing (push) Successful in 1m55s
Quality Check / Static Analysis (push) Successful in 2m5s
Quality Check / Linting (pull_request) Successful in 1m56s
Quality Check / Testing (pull_request) Successful in 1m54s
Quality Check / Static Analysis (pull_request) Successful in 1m58s
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:12:20 +02:00
59e3bd1d53
NOTICKET: Update TestData Generation
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:12:20 +02:00
0e4d58dc50
NOTICKET: Disable Parallel Unittests
All checks were successful
Quality Check / Validate OAS (push) Successful in 32s
Quality Check / Linting (push) Successful in 1m7s
Quality Check / Static Analysis (push) Successful in 1m11s
Quality Check / Testing (push) Successful in 1m10s
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:10:59 +02:00
2e424484c3
NOTICKET: Add ObjectMapper and MockAPI to base IntegrationTest
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:10:53 +02:00
cdb60f0d86
NOTICKET: Change Java Datetime Library to be follow Spring Context.
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
2024-10-09 11:10:46 +02:00
Rajbir Singh
d84647f9e6 .
Some checks failed
Quality Check / Validate OAS (push) Successful in 34s
Quality Check / Linting (push) Failing after 52s
Quality Check / Static Analysis (push) Failing after 1m0s
Quality Check / Testing (push) Successful in 1m4s
2024-10-07 14:27:22 +02:00
6 changed files with 125 additions and 89 deletions

View file

@ -1,24 +1,12 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test" type="GradleRunConfiguration" factoryName="Gradle"> <configuration default="false" name="Test" type="JUnit" factoryName="JUnit">
<ExternalSystemSettings> <module name="Project_Management_Tool.test" />
<option name="executionName" /> <option name="PACKAGE_NAME" value="" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="MAIN_CLASS_NAME" value="" />
<option name="externalSystemIdString" value="GRADLE" /> <option name="METHOD_NAME" value="" />
<option name="scriptParameters" value="" /> <option name="TEST_OBJECT" value="package" />
<option name="taskDescriptions"> <method v="2">
<list /> <option name="Make" enabled="true" />
</option> </method>
<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>

View file

@ -4,7 +4,7 @@
"invokerPackage": "de.hmmh.pmt", "invokerPackage": "de.hmmh.pmt",
"java8": false, "java8": false,
"java11": true, "java11": true,
"dateLibrary": "java11", "dateLibrary": "java8-localdatetime",
"library": "spring-boot3", "library": "spring-boot3",
"defaultInterfaces": false, "defaultInterfaces": false,
"serializableModel": true "serializableModel": true

View file

@ -41,6 +41,16 @@ 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();

View file

@ -1,17 +1,22 @@
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.List; import java.util.HashMap;
import java.util.Map;
@SpringBootTest @SpringBootTest
@AutoConfigureMockMvc(addFilters = false) @AutoConfigureMockMvc(addFilters = false)
@ -23,8 +28,15 @@ 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();
@ -35,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",
"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)
);
projectRepository.save(project1); Project researchLabProject = new Project();
projectRepository.save(project2); researchLabProject.setName("Underwater Research Lab");
projectRepository.save(project3); researchLabProject.setGoal( "Discover new marine species!");
projectRepository.save(project4); researchLabProject.setCustomerId(73L);
projectRepository.save(project5); researchLabProject.setAdministratorId(202L);
researchLabProject.setStart(LocalDateTime.of(2025, 5, 22, 8, 45));
researchLabProject.setPlannedEnd(LocalDateTime.of(2026, 5, 22, 8, 45));
projects.put("research-lab", researchLabProject);
return List.of( Project spaceStationProject = new Project();
project1, spaceStationProject.setName("International Space Station Expansion");
project2, spaceStationProject.setGoal("Build new modules for extended research.");
project3, spaceStationProject.setCustomerId(85L);
project4, spaceStationProject.setAdministratorId(150L);
project5 spaceStationProject.setStart(LocalDateTime.of(2024, 10, 15, 10, 0));
); 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;
} }
} }

View file

@ -0,0 +1,31 @@
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())
;
}
}

View file

@ -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"))