Compare commits
3 commits
089b777ea8
...
7fc105308a
Author | SHA1 | Date | |
---|---|---|---|
7fc105308a | |||
3dd06fbf0c | |||
ce038dc725 |
4 changed files with 34 additions and 25 deletions
|
@ -49,6 +49,9 @@ components:
|
|||
plannedEnd:
|
||||
type: string
|
||||
format: date-time
|
||||
realEnd:
|
||||
type: string
|
||||
format: date-time
|
||||
CreateProjectDTO:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -74,23 +74,13 @@ public class ApiController implements DefaultApi {
|
|||
|
||||
@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);
|
||||
return ResponseEntity.ok(mapper.mapToGet(project));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package de.hmmh.pmt.util;
|
||||
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
||||
import de.hmmh.pmt.dtos.CreatedProjectDTO;
|
||||
import de.hmmh.pmt.dtos.Employee;
|
||||
import de.hmmh.pmt.dtos.Qualification ;
|
||||
import de.hmmh.pmt.dtos.*;
|
||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||
import de.hmmh.pmt.employee.dtos.QualificationGetDTO;
|
||||
import de.hmmh.pmt.dtos.UpdateProjectDTO;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -37,6 +34,19 @@ public class Mapper {
|
|||
return dto;
|
||||
}
|
||||
|
||||
public GetAllProjectInfoDTO mapToGet(Project project) {
|
||||
GetAllProjectInfoDTO dto = new GetAllProjectInfoDTO();
|
||||
dto.setId(project.getId());
|
||||
dto.setName(project.getName());
|
||||
dto.setGoal(project.getGoal());
|
||||
dto.setCustomerId(project.getCustomerId());
|
||||
dto.setAdministratorId(project.getAdministratorId());
|
||||
dto.setStart(project.getStart());
|
||||
dto.setPlannedEnd(project.getPlannedEnd());
|
||||
dto.setRealEnd(project.getRealEnd());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
|
||||
Employee dto = new Employee();
|
||||
dto.setId(employeeResponseDTO.getId());
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
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 java.util.Map;
|
||||
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;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
|
||||
public class GetProjectInfoTest extends IntegrationTest {
|
||||
|
||||
|
@ -22,10 +19,19 @@ public class GetProjectInfoTest extends IntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public RequestBuilder getProjectInfo(Long projectId) throws Exception {
|
||||
return MockMvcRequestBuilders
|
||||
.get("/project/" + projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON);
|
||||
void getProjectInfo() throws Exception {
|
||||
Map<String, Project> allProjects = createTestProjectData();
|
||||
Project spaceStation = allProjects.get("space-station");
|
||||
mvc
|
||||
.perform(get(baseUri + "/project/" +spaceStation.getId()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id").value(spaceStation.getId()))
|
||||
.andExpect(jsonPath("$.name").value(spaceStation.getName()))
|
||||
.andExpect(jsonPath("$.goal").value(spaceStation.getGoal()))
|
||||
.andExpect(jsonPath("$.customerId").value(spaceStation.getCustomerId()))
|
||||
.andExpect(jsonPath("$.administratorId").value(spaceStation.getAdministratorId()))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue