Compare commits

..

8 commits

Author SHA1 Message Date
Rajbir Singh
13f565907c PMT-26 refactor GetAllEmployeesByProjectTest.java
All checks were successful
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m3s
Quality Check / Linting (push) Successful in 2m5s
Quality Check / Linting (pull_request) Successful in 2m9s
Quality Check / Testing (push) Successful in 2m21s
Quality Check / Static Analysis (push) Successful in 2m27s
Quality Check / Testing (pull_request) Successful in 2m18s
Quality Check / Static Analysis (pull_request) Successful in 2m22s
2024-10-23 13:01:32 +02:00
Rajbir Singh
413ee85e1a PMT-26 refactor pmt,yml
Some checks failed
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Successful in 2m7s
Quality Check / Linting (pull_request) Successful in 2m13s
Quality Check / Testing (push) Successful in 2m22s
Quality Check / Static Analysis (push) Failing after 2m26s
Quality Check / Testing (pull_request) Successful in 2m19s
Quality Check / Static Analysis (pull_request) Failing after 2m22s
2024-10-23 12:56:34 +02:00
Rajbir Singh
be0b7b8f7d PMT-26 created Test
Some checks failed
Quality Check / Validate OAS (push) Successful in 50s
Quality Check / Validate OAS (pull_request) Successful in 1m7s
Quality Check / Linting (push) Successful in 2m6s
Quality Check / Linting (pull_request) Successful in 2m13s
Quality Check / Testing (push) Successful in 2m21s
Quality Check / Static Analysis (push) Failing after 2m25s
Quality Check / Testing (pull_request) Successful in 2m18s
Quality Check / Static Analysis (pull_request) Failing after 2m21s
2024-10-23 12:09:47 +02:00
Rajbir Singh
8fa066b374 PMT-26 refactor naming pmt.yml, ApiController, Mapper
All checks were successful
Quality Check / Validate OAS (push) Successful in 53s
Quality Check / Validate OAS (pull_request) Successful in 1m6s
Quality Check / Linting (push) Successful in 2m3s
Quality Check / Linting (pull_request) Successful in 2m9s
Quality Check / Testing (push) Successful in 2m23s
Quality Check / Static Analysis (push) Successful in 2m29s
Quality Check / Testing (pull_request) Successful in 2m19s
Quality Check / Static Analysis (pull_request) Successful in 2m22s
2024-10-23 08:46:53 +02:00
Rajbir Singh
b3327ad351 PMT-26 changed pmt.yml, Mapper, ApiController
All checks were successful
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Successful in 1m10s
Quality Check / Static Analysis (push) Successful in 1m17s
Quality Check / Testing (push) Successful in 1m16s
Quality Check / Validate OAS (pull_request) Successful in 33s
Quality Check / Linting (pull_request) Successful in 1m9s
Quality Check / Static Analysis (pull_request) Successful in 1m18s
Quality Check / Testing (pull_request) Successful in 1m16s
2024-10-22 18:15:14 +02:00
Rajbir Singh
94298293a8 PMT-26 refactor try/catch getAListOfAllEmployeesFromASpecificProject
Some checks failed
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Failing after 49s
Quality Check / Static Analysis (push) Failing after 50s
Quality Check / Testing (push) Failing after 51s
2024-10-22 15:50:36 +02:00
Rajbir Singh
9692f1f179 PMT-26 get all Employees from a specific Project
Some checks failed
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Failing after 50s
Quality Check / Static Analysis (push) Failing after 51s
Quality Check / Testing (push) Failing after 50s
2024-10-22 15:10:13 +02:00
Rajbir Singh
f941cad4b9 PMT-26 Define Endpoint 2024-10-21 22:24:48 +02:00
4 changed files with 5 additions and 111 deletions

View file

@ -250,37 +250,6 @@ paths:
500:
$ref: "#/components/responses/InternalError"
/project/{id}/employee/{employeeId}:
delete:
operationId: "removeEmployeeFromProject"
description: "Removes an employee from a Project"
parameters:
- in: path
name: id
schema:
type: integer
format: int64
required: true
- in: path
name: employeeId
schema:
type: integer
format: int64
required: true
responses:
204:
description: "Deletes the employee from the Project"
401:
$ref: "#/components/responses/Unauthorized"
404:
$ref: "#/components/responses/NotFound"
409:
$ref: "#/components/responses/Conflict"
500:
$ref: "#/components/responses/InternalError"
503:
$ref: "#/components/responses/ServiceUnavailable"
/project/{id}/employees:
get:
description: "getAllEmployees"

View file

@ -1,11 +1,12 @@
package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.db.*;
import de.hmmh.pmt.db.Allocation;
import de.hmmh.pmt.db.AllocationRepository;
import de.hmmh.pmt.db.Project;
import de.hmmh.pmt.db.ProjectRepository;
import de.hmmh.pmt.dtos.*;
import de.hmmh.pmt.employee.ApiClientFactory;
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
import de.hmmh.pmt.oas.DefaultApi;
import de.hmmh.pmt.util.Mapper;
@ -143,17 +144,6 @@ public class ApiController implements DefaultApi {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Override
public ResponseEntity<Void> removeEmployeeFromProject(Long id, Long employeeId){
Optional<Allocation> allocation = allocationRepository.findById(new AllocationId(id, employeeId));
if (allocation.isEmpty()){
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
allocationRepository.delete(allocation.get());
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Override
public ResponseEntity<ProjectEmployeesDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
if (!projectRepository.existsById(id)) {

View file

@ -165,18 +165,12 @@ public abstract class IntegrationTest {
allocation1ToOverlapA.setRole(TEST_QUALIFICATION_A_ID);
allocations.put("1>overlap-a", allocation1ToOverlapA);
Allocation allocation1ToSpaceStation = new Allocation();
allocation1ToSpaceStation.setProject(allProjects.get("space-station"));
allocation1ToSpaceStation.setEmployeeId(TEST_EMPLOYEE_A_ID);
allocation1ToSpaceStation.setRole(TEST_QUALIFICATION_A_ID);
allocations.put("1>space-station", allocation1ToSpaceStation);
Allocation allocation1ToAiResearch = new Allocation();
allocation1ToAiResearch.setProject(allProjects.get("ai-research"));
allocation1ToAiResearch.setEmployeeId(TEST_EMPLOYEE_A_ID);
allocation1ToAiResearch.setRole(TEST_QUALIFICATION_A_ID);
allocations.put("1>ai-research", allocation1ToAiResearch);
allocationRepository.saveAllAndFlush(allocations.values());
return allocations;
}

View file

@ -1,59 +0,0 @@
package de.hmmh.pmt.project;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.web.client.HttpClientErrorException;
import de.hmmh.pmt.IntegrationTest;
import de.hmmh.pmt.db.Allocation;
import de.hmmh.pmt.db.Project;
import de.hmmh.pmt.dtos.AddEmployeeDTO;
public class DeleteEmployeeTest extends IntegrationTest {
@Test
void shouldNotDeleteEmployeeWhenProjectIsNotFound() throws Exception {
mvc
.perform(delete(baseUri + "/project/1"))
.andExpect(status().isNotFound())
;
}
@Test
void shouldNotDeleteEmployeeWhenEmployeeIsNotAllocated() throws Exception {
when(this.mockEmployeeApi.findById(Mockito.anyLong()))
.thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
Map<String, Project> allProjects = createTestProjectData();
this.mvc
.perform(getRequest(allProjects.get("research-lab").getId(), 0L))
.andExpect(status().isNotFound());
}
@Test
void employeeSuccessfullyDeletedFromProject() throws Exception {
Map<String, Project> allProjects = createTestProjectData();
Map<String, Allocation> allAllocations = createTestAllocationData(allProjects);
Allocation allocation = allAllocations.get("1>space-station");
this.mvc
.perform(getRequest(allocation.getProjectId(),allocation.getEmployeeId()))
.andExpect(status().isNoContent());
}
private RequestBuilder getRequest(Long projectId, Long employeeId) {
return MockMvcRequestBuilders
.delete(baseUri + "/project/" + projectId + "/employee/" + employeeId);
}
}