UsersController.java

1
package edu.ucsb.cs156.courses.controllers;
2
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
import edu.ucsb.cs156.courses.repositories.UserRepository;
6
import io.swagger.v3.oas.annotations.Operation;
7
import io.swagger.v3.oas.annotations.tags.Tag;
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.data.domain.Pageable;
10
import org.springframework.http.ResponseEntity;
11
import org.springframework.security.access.prepost.PreAuthorize;
12
import org.springframework.web.bind.annotation.GetMapping;
13
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RestController;
15
16
@Tag(name = "User information (admin only)")
17
@RequestMapping("/api/admin/users")
18
@RestController
19
public class UsersController extends ApiController {
20
  @Autowired UserRepository userRepository;
21
  @Autowired ObjectMapper mapper;
22
23
  @Operation(summary = "Get a paged list of users")
24
  @PreAuthorize("hasRole('ROLE_ADMIN')")
25
  @GetMapping("/paged")
26
  public ResponseEntity<String> usersPaged(Pageable pageable) throws JsonProcessingException {
27
28
    var usersPage = userRepository.findAll(pageable);
29
    String body = mapper.writeValueAsString(usersPage);
30 1 1. usersPaged : replaced return value with null for edu/ucsb/cs156/courses/controllers/UsersController::usersPaged → KILLED
    return ResponseEntity.ok().body(body);
31
  }
32
}

Mutations

30

1.1
Location : usersPaged
Killed by : edu.ucsb.cs156.courses.controllers.UsersControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.UsersControllerTests]/[method:users_paged__admin_logged_in()]
replaced return value with null for edu/ucsb/cs156/courses/controllers/UsersController::usersPaged → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0