• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torresj / community-api / 28

16 Jun 2025 10:53AM UTC coverage: 74.063% (-8.8%) from 82.813%
28

push

circleci

Jaime Torres Benavente
fixing test errors

237 of 320 relevant lines covered (74.06%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/src/main/java/com/torresj/community/controllers/UserController.java
1
package com.torresj.community.controllers;
2

3
import com.torresj.community.dtos.UserDto;
4
import com.torresj.community.exceptions.CommunityNotFoundException;
5
import com.torresj.community.exceptions.UserNotFoundException;
6
import com.torresj.community.services.UserService;
7
import io.swagger.v3.oas.annotations.Operation;
8
import io.swagger.v3.oas.annotations.Parameter;
9
import io.swagger.v3.oas.annotations.media.ArraySchema;
10
import io.swagger.v3.oas.annotations.media.Content;
11
import io.swagger.v3.oas.annotations.media.Schema;
12
import io.swagger.v3.oas.annotations.responses.ApiResponse;
13
import io.swagger.v3.oas.annotations.responses.ApiResponses;
14
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
15
import lombok.RequiredArgsConstructor;
16
import lombok.extern.slf4j.Slf4j;
17
import org.springframework.http.ResponseEntity;
18
import org.springframework.web.bind.annotation.GetMapping;
19
import org.springframework.web.bind.annotation.PathVariable;
20
import org.springframework.web.bind.annotation.RequestMapping;
21
import org.springframework.web.bind.annotation.RestController;
22

23
import java.util.List;
24

25
@RestController
26
@RequestMapping("/v1/users")
27
@Slf4j
1✔
28
@RequiredArgsConstructor
29
public class UserController {
30

31
    private final UserService userService;
32

33
    @Operation(summary = "Get users")
34
    @ApiResponses(
35
            value = {
36
                    @ApiResponse(
37
                            responseCode = "200",
38
                            description = "Success",
39
                            content = {
40
                                    @Content(
41
                                            mediaType = "application/json",
42
                                            array = @ArraySchema(schema = @Schema(implementation = UserDto.class)))
43
                            }),
44
            })
45
    @GetMapping()
46
    @SecurityRequirement(name = "Bearer Authentication")
47
    public ResponseEntity<List<UserDto>> get() throws CommunityNotFoundException {
48
        log.info("Getting Users");
1✔
49
        List<UserDto> users = userService.get();
1✔
50
        log.info("Users found: {}", users.size());
1✔
51
        return ResponseEntity.ok(users);
1✔
52
    }
53

54
    @GetMapping("/{id}")
55
    @SecurityRequirement(name = "Bearer Authentication")
56
    @Operation(summary = "Get user by ID")
57
    @ApiResponses(
58
            value = {
59
                    @ApiResponse(
60
                            responseCode = "200",
61
                            description = "User found",
62
                            content = {
63
                                    @Content(
64
                                            mediaType = "application/json",
65
                                            schema = @Schema(implementation = UserDto.class))
66
                            }),
67
                    @ApiResponse(responseCode = "404", description = "Not found", content = @Content),
68
            })
69
    ResponseEntity<UserDto> getUserById(@Parameter(description = "User id") @PathVariable long id)
70
            throws UserNotFoundException, CommunityNotFoundException {
71
        log.info("Getting user by id {}", id);
×
72
        var user = userService.get(id);
×
73
        log.info("User found");
×
74
        return ResponseEntity.ok(user);
×
75
    }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc