diff --git a/src/main/java/de/szut/lf8_starter/project/ProjectController.java b/src/main/java/de/szut/lf8_starter/project/ProjectController.java index fe0991b..61ee843 100644 --- a/src/main/java/de/szut/lf8_starter/project/ProjectController.java +++ b/src/main/java/de/szut/lf8_starter/project/ProjectController.java @@ -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 diff --git a/src/main/java/de/szut/lf8_starter/project/ProjectMapper.java b/src/main/java/de/szut/lf8_starter/project/ProjectMapper.java index 6567749..fa60491 100644 --- a/src/main/java/de/szut/lf8_starter/project/ProjectMapper.java +++ b/src/main/java/de/szut/lf8_starter/project/ProjectMapper.java @@ -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()); diff --git a/src/main/java/de/szut/lf8_starter/project/dto/GetProjectDto.java b/src/main/java/de/szut/lf8_starter/project/dto/GetProjectDto.java index cc337c7..c90cd50 100644 --- a/src/main/java/de/szut/lf8_starter/project/dto/GetProjectDto.java +++ b/src/main/java/de/szut/lf8_starter/project/dto/GetProjectDto.java @@ -12,6 +12,8 @@ import java.util.List; @Getter @Setter public class GetProjectDto { + private long id; + @NotBlank private String name; diff --git a/src/main/java/de/szut/lf8_starter/project/dto/ProjectGetDto.java b/src/main/java/de/szut/lf8_starter/project/dto/ProjectGetDto.java deleted file mode 100644 index 4d53212..0000000 --- a/src/main/java/de/szut/lf8_starter/project/dto/ProjectGetDto.java +++ /dev/null @@ -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 employees; - - private long contractor; - - private String contractorName; - - private String comment; - - private LocalDate startDate; - - private LocalDate endDate; -} diff --git a/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java b/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java index ea9e354..8ab3fd8 100644 --- a/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java +++ b/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java @@ -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; diff --git a/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java index 0409f36..361e585 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java @@ -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))); }