Compare commits

...

3 commits

Author SHA1 Message Date
089b777ea8
PMT-37-added uncompleted Test cases
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 1m20s
Quality Check / Testing (push) Successful in 1m19s
2024-10-23 15:31:47 +02:00
8ea7bf798f
PMT-37-added endpoint and DTO specification 2024-10-23 15:31:02 +02:00
6eb1b5bda8
PMT-37-added Controller Method 2024-10-23 15:30:13 +02:00
3 changed files with 100 additions and 0 deletions

View file

@ -27,6 +27,28 @@ components:
type: array type: array
items: items:
$ref: "#/components/schemas/ProjectInfo" $ref: "#/components/schemas/ProjectInfo"
GetAllProjectInfoDTO:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
goal:
type: string
customerId:
type: integer
format: int64
administratorId:
type: integer
format: int64
start:
type: string
format: date-time
plannedEnd:
type: string
format: date-time
CreateProjectDTO: CreateProjectDTO:
type: object type: object
properties: properties:
@ -213,6 +235,31 @@ paths:
$ref: "#/components/responses/ServiceUnavailable" $ref: "#/components/responses/ServiceUnavailable"
/project/{id}: /project/{id}:
get:
operationId: "getProjectInfo"
description: "Get a list of all Project Informations"
parameters:
- in: path
name: id
schema:
type: integer
format: int64
required: true
responses:
200:
description: "Project Info recieved"
content:
application/json:
schema:
$ref: "#/components/schemas/GetAllProjectInfoDTO"
401:
$ref: "#/components/responses/Unauthorized"
404:
$ref: "#/components/responses/NotFound"
500:
$ref: "#/components/responses/InternalError"
503:
$ref: "#/components/responses/ServiceUnavailable"
post: post:
operationId: "addEmployee" operationId: "addEmployee"
description: "Adds an employee to a specific Project" description: "Adds an employee to a specific Project"

View file

@ -72,6 +72,28 @@ public class ApiController implements DefaultApi {
return ResponseEntity.ok(response); return ResponseEntity.ok(response);
} }
@Override
public ResponseEntity<GetAllProjectInfoDTO> getProjectInfo(Long id){
GetAllProjectInfoDTO response = new GetAllProjectInfoDTO();
Optional<Project> optionalProject = projectRepository.findById(id);
if (optionalProject.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Project project = optionalProject.get();
response.setId(project.getId());
response.setName(project.getName());
response.setGoal(project.getGoal());
response.setCustomerId(project.getCustomerId());
response.setAdministratorId(project.getAdministratorId());
response.setStart(project.getStart());
response.setPlannedEnd(project.getPlannedEnd());
return ResponseEntity.ok(response);
}
@Override @Override
public ResponseEntity<Void> updateProject(Long id, UpdateProjectDTO body) { public ResponseEntity<Void> updateProject(Long id, UpdateProjectDTO body) {
Optional<Project> optionalProject = projectRepository.findById(id); Optional<Project> optionalProject = projectRepository.findById(id);

View file

@ -0,0 +1,31 @@
package de.hmmh.pmt.project;
import static org.hamcrest.Matchers.empty;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import de.hmmh.pmt.IntegrationTest;
public class GetProjectInfoTest extends IntegrationTest {
@Test
void noProject() throws Exception {
mvc
.perform(get(baseUri + "/project/1"))
.andExpect(status().isNotFound());
}
@Test
public RequestBuilder getProjectInfo(Long projectId) throws Exception {
return MockMvcRequestBuilders
.get("/project/" + projectId)
.contentType(MediaType.APPLICATION_JSON);
}
}