feat: Write Integration test for Create Project Route and ensure using Snake Case in JSON Format (SCRUM-7) #14
@ -1,43 +0,0 @@
|
|||||||
package de.szut.lf8_starter.project;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class GetProjectDto {
|
|
||||||
@NotBlank
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private long leadingEmployee;
|
|
||||||
|
|
||||||
private List<Long> employees;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private long contractor;
|
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String contractorName;
|
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@JsonFormat(pattern = "dd.MM.yyyy")
|
|
||||||
private LocalDate startDate;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@JsonFormat(pattern = "dd.MM.yyyy")
|
|
||||||
private LocalDate plannedEndDate;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@JsonFormat(pattern = "dd.MM.yyyy")
|
|
||||||
private LocalDate endDate;
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package de.szut.lf8_starter.project.dto;
|
|
||||||
|
|
||||||
import de.szut.lf8_starter.project.GetProjectDto;
|
|
||||||
import de.szut.lf8_starter.project.ProjectEntity;
|
|
||||||
import de.szut.lf8_starter.project.ProjectMapper;
|
|
||||||
import de.szut.lf8_starter.project.ProjectService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "/projects")
|
|
||||||
public class CreateProjectAction {
|
|
||||||
private final ProjectService projectService;
|
|
||||||
private final ProjectMapper projectMapper;
|
|
||||||
|
|
||||||
public CreateProjectAction(ProjectService projectService, ProjectMapper mappingService) {
|
|
||||||
this.projectService = projectService;
|
|
||||||
this.projectMapper = mappingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "Creates a new Project")
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(responseCode = "201", description = "created project", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = GetProjectDto.class))}),
|
|
||||||
@ApiResponse(responseCode = "400", description = "invalid JSON posted", content = @Content),
|
|
||||||
@ApiResponse(responseCode = "401", description = "not authorized", content = @Content)})
|
|
||||||
@PostMapping
|
|
||||||
public GetProjectDto create(@RequestBody @Valid CreateProjectDto createProjectDto) {
|
|
||||||
ProjectEntity projectEntity = this.projectMapper.mapCreateDtoToEntity(createProjectDto);
|
|
||||||
|
|
||||||
projectEntity = this.projectService.create(projectEntity);
|
|
||||||
|
|
||||||
return this.projectMapper.mapToGetDto(projectEntity);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user