feat(project): update project DTO and controller mapping
This commit is contained in:
parent
bee9d307fa
commit
5ae5aca076
@ -1,7 +1,6 @@
|
||||
package de.szut.lf8_starter.project;
|
||||
|
||||
import de.szut.lf8_starter.project.dto.GetProjectDto;
|
||||
import de.szut.lf8_starter.project.dto.ProjectGetDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -25,7 +24,7 @@ public class ProjectController {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "all projects",
|
||||
content = {@Content(mediaType = "application/json",
|
||||
schema = @Schema(implementation = ProjectGetDto.class))}),
|
||||
schema = @Schema(implementation = GetProjectDto.class))}),
|
||||
@ApiResponse(responseCode = "401", description = "not authorized",
|
||||
content = @Content)})
|
||||
@GetMapping
|
||||
|
@ -25,6 +25,7 @@ public class ProjectMapper {
|
||||
public GetProjectDto mapToGetDto(ProjectEntity projectEntity) {
|
||||
GetProjectDto getProjectDto = new GetProjectDto();
|
||||
|
||||
getProjectDto.setId(projectEntity.getId());
|
||||
getProjectDto.setName(projectEntity.getName());
|
||||
getProjectDto.setComment(projectEntity.getComment());
|
||||
getProjectDto.setLeadingEmployee(projectEntity.getLeadingEmployee());
|
||||
|
@ -12,6 +12,8 @@ import java.util.List;
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetProjectDto {
|
||||
private long id;
|
||||
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
package de.szut.lf8_starter.project.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ProjectGetDto {
|
||||
private long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private long leadingEmployee;
|
||||
|
||||
private List<Long> employees;
|
||||
|
||||
private long contractor;
|
||||
|
||||
private String contractorName;
|
||||
|
||||
private String comment;
|
||||
|
||||
private LocalDate startDate;
|
||||
|
||||
private LocalDate endDate;
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
|
@ -5,6 +5,7 @@ import de.szut.lf8_starter.project.ProjectRepository;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
@ -18,7 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@AutoConfigureMockMvc
|
||||
@AutoConfigureMockMvc(addFilters = false)
|
||||
public class ProjectFindAll {
|
||||
@Autowired
|
||||
private ProjectRepository projectRepository;
|
||||
@ -50,10 +51,10 @@ public class ProjectFindAll {
|
||||
.andExpect(jsonPath("$[0].comment").value("comment"))
|
||||
.andExpect(jsonPath("$[0].contractor").value(1))
|
||||
.andExpect(jsonPath("$[0].contractorName").value("contractorName"))
|
||||
.andExpect(jsonPath("$[0].endDate").value("2024-01-01"))
|
||||
.andExpect(jsonPath("$[0].endDate").value("01.01.2024"))
|
||||
.andExpect(jsonPath("$[0].leadingEmployee").value(1))
|
||||
.andExpect(jsonPath("$[0].name").value("name"))
|
||||
.andExpect(jsonPath("$[0].startDate").value("2021-01-01"))
|
||||
.andExpect(jsonPath("$[0].startDate").value("01.01.2021"))
|
||||
.andExpect(jsonPath("$[0].employees").isArray())
|
||||
.andExpect(jsonPath("$[0].employees", hasSize(3)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user