Compare commits
3 commits
cec89e2766
...
089b777ea8
Author | SHA1 | Date | |
---|---|---|---|
089b777ea8 | |||
8ea7bf798f | |||
6eb1b5bda8 |
3 changed files with 100 additions and 0 deletions
47
api/pmt.yml
47
api/pmt.yml
|
@ -27,6 +27,28 @@ components:
|
|||
type: array
|
||||
items:
|
||||
$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:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -213,6 +235,31 @@ paths:
|
|||
$ref: "#/components/responses/ServiceUnavailable"
|
||||
|
||||
/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:
|
||||
operationId: "addEmployee"
|
||||
description: "Adds an employee to a specific Project"
|
||||
|
|
|
@ -72,6 +72,28 @@ public class ApiController implements DefaultApi {
|
|||
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
|
||||
public ResponseEntity<Void> updateProject(Long id, UpdateProjectDTO body) {
|
||||
Optional<Project> optionalProject = projectRepository.findById(id);
|
||||
|
|
31
src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java
Normal file
31
src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue