feat: Write Integration test for Create Project Route and ensure using Snake Case in JSON Format (SCRUM-7) (!14)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de> Reviewed-on: #14 Reviewed-by: Jan Gleytenhoover <krisellp9@gmail.com>
This commit is contained in:
parent
f53a317e72
commit
013e964be6
6 changed files with 89 additions and 31 deletions
|
@ -8,10 +8,8 @@ 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;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/projects")
|
||||
|
@ -30,6 +28,7 @@ public class CreateProjectAction {
|
|||
@ApiResponse(responseCode = "400", description = "invalid JSON posted", content = @Content),
|
||||
@ApiResponse(responseCode = "401", description = "not authorized", content = @Content)})
|
||||
@PostMapping
|
||||
@ResponseStatus(code = HttpStatus.CREATED)
|
||||
public GetProjectDto create(@RequestBody @Valid CreateProjectDto createProjectDto) {
|
||||
ProjectEntity projectEntity = this.projectMapper.mapCreateDtoToEntity(createProjectDto);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.szut.lf8_starter.project.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
|
@ -11,6 +13,7 @@ import java.util.List;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class CreateProjectDto {
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.szut.lf8_starter.project.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
|
@ -11,35 +13,22 @@ import java.util.List;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class GetProjectDto {
|
||||
private long id;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
|
Reference in a new issue