feat: Write Integration test for Create Project Route and ensure using Snake Case in JSON Format (SCRUM-7) (!14)
All checks were successful
Quality Check / Tests (push) Successful in 53s
Quality Check / Checkstyle Main (push) Successful in 56s
Release / Release (push) Successful in 38s

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:
Phan Huy Tran 2024-09-25 12:27:34 +00:00
parent f53a317e72
commit 013e964be6
6 changed files with 89 additions and 31 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;
}