StatsController.java

1
package edu.ucsb.cs156.diningcachingproxy.controller;
2
3
import edu.ucsb.cs156.diningcachingproxy.services.StatsService;
4
import io.swagger.v3.oas.annotations.Operation;
5
import io.swagger.v3.oas.annotations.tags.Tag;
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.security.access.prepost.PreAuthorize;
8
import org.springframework.web.bind.annotation.GetMapping;
9
import org.springframework.web.bind.annotation.RequestMapping;
10
import org.springframework.web.bind.annotation.RestController;
11
12
/** Exposes the four in-memory cache performance counters. */
13
@Tag(name = "Stats")
14
@RequestMapping("/api/stats")
15
@RestController
16
public class StatsController {
17
18
  @Autowired private StatsService statsService;
19
20
  public record StatsDTO(
21
      long totalRequests, long cacheHits, long cacheMisses, double hitRatePercentage) {}
22
23
  @Operation(summary = "Get cache performance statistics since the proxy started up")
24
  @PreAuthorize("hasRole('ROLE_USER')")
25
  @GetMapping("")
26
  public StatsDTO getStats() {
27 1 1. getStats : replaced return value with null for edu/ucsb/cs156/diningcachingproxy/controller/StatsController::getStats → KILLED
    return new StatsDTO(
28
        statsService.getTotalRequests(),
29
        statsService.getCacheHits(),
30
        statsService.getCacheMisses(),
31
        statsService.getHitRatePercentage());
32
  }
33
}

Mutations

27

1.1
Location : getStats
Killed by : edu.ucsb.cs156.diningcachingproxy.controller.StatsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.diningcachingproxy.controller.StatsControllerTests]/[method:logged_in_user_can_get_stats()]
replaced return value with null for edu/ucsb/cs156/diningcachingproxy/controller/StatsController::getStats → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1