PoolController.java

1
package org.cardanofoundation.explorer.api.controller;
2
3
import jakarta.validation.Valid;
4
5
import lombok.RequiredArgsConstructor;
6
7
import org.springframework.data.domain.Sort;
8
import org.springframework.http.ResponseEntity;
9
import org.springframework.validation.annotation.Validated;
10
import org.springframework.web.bind.annotation.GetMapping;
11
import org.springframework.web.bind.annotation.PathVariable;
12
import org.springframework.web.bind.annotation.RequestMapping;
13
import org.springframework.web.bind.annotation.RestController;
14
15
import io.swagger.v3.oas.annotations.Operation;
16
import io.swagger.v3.oas.annotations.Parameter;
17
import io.swagger.v3.oas.annotations.tags.Tag;
18
import org.springdoc.core.annotations.ParameterObject;
19
20
import org.cardanofoundation.explorer.api.config.LogMessage;
21
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
22
import org.cardanofoundation.explorer.api.model.response.pool.PoolRangeValuesResponse;
23
import org.cardanofoundation.explorer.api.model.response.pool.PoolTxResponse;
24
import org.cardanofoundation.explorer.api.model.response.pool.StakePoolsChartResponse;
25
import org.cardanofoundation.explorer.api.model.response.pool.TxPoolCertificateHistory;
26
import org.cardanofoundation.explorer.api.service.PoolCertificateService;
27
import org.cardanofoundation.explorer.api.service.PoolRegistrationService;
28
import org.cardanofoundation.explorer.api.service.PoolService;
29
import org.cardanofoundation.explorer.common.entity.ledgersync.PoolRetire_;
30
import org.cardanofoundation.explorer.common.entity.ledgersync.PoolUpdate_;
31
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
32
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
33
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
34
35
@RestController
36
@RequestMapping("/api/v1/pools")
37
@RequiredArgsConstructor
38
@Validated
39
@Tag(name = "pools", description = "The pool APIs")
40
public class PoolController {
41
42
  private final PoolRegistrationService poolRegistrationService;
43
  private final PoolCertificateService poolCertificateService;
44
  private final PoolService poolService;
45
46
  @GetMapping("/registration")
47
  @LogMessage
48
  @Operation(
49
      summary = "Get list of pool registrations",
50
      tags = {"pools"})
51
  public ResponseEntity<BaseFilterResponse<PoolTxResponse>> getDataForPoolRegistration(
52
      @ParameterObject
53
          @PaginationValid
54
          @PaginationDefault(
55
              size = 20,
56
              sort = {PoolUpdate_.REGISTERED_TX_ID},
57
              direction = Sort.Direction.DESC)
58
          @Valid
59
          Pagination pagination) {
60 1 1. getDataForPoolRegistration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getDataForPoolRegistration → SURVIVED
    return ResponseEntity.ok(
61
        poolRegistrationService.getDataForPoolRegistration(pagination.toPageable()));
62
  }
63
64
  @GetMapping("/de-registration")
65
  @LogMessage
66
  @Operation(
67
      summary = "Get list of pool de-registrations",
68
      tags = {"pools"})
69
  public ResponseEntity<BaseFilterResponse<PoolTxResponse>> getDataForPoolDeRegistration(
70
      @ParameterObject
71
          @PaginationValid
72
          @PaginationDefault(
73
              size = 20,
74
              sort = {PoolRetire_.ANNOUNCED_TX_ID},
75
              direction = Sort.Direction.DESC)
76
          @Valid
77
          Pagination pagination) {
78 1 1. getDataForPoolDeRegistration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getDataForPoolDeRegistration → SURVIVED
    return ResponseEntity.ok(
79
        poolRegistrationService.getDataForPoolDeRegistration(pagination.toPageable()));
80
  }
81
82
  @GetMapping("/certificates-history/{poolViewOrHash}")
83
  @LogMessage
84
  @Operation(
85
      summary = "Get list of pool certificates history",
86
      tags = {"pools"})
87
  public ResponseEntity<BaseFilterResponse<TxPoolCertificateHistory>> getTxPoolCertificatesHistory(
88
      @PathVariable @Parameter(description = "The pool view or pool hash") String poolViewOrHash,
89
      @ParameterObject
90
          @PaginationValid
91
          @PaginationDefault(
92
              size = 20,
93
              sort = {"createdAt"},
94
              direction = Sort.Direction.DESC)
95
          @Valid
96
          Pagination pagination) {
97 1 1. getTxPoolCertificatesHistory : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getTxPoolCertificatesHistory → KILLED
    return ResponseEntity.ok(
98
        poolCertificateService.getTxPoolCertificateHistory(
99
            poolViewOrHash, pagination.toPageable()));
100
  }
101
102
  @GetMapping("/range-values-for-filter")
103
  @LogMessage
104
  @Operation(
105
      summary = "Get range value to filter on pool overview page",
106
      tags = {"pools"})
107
  public ResponseEntity<PoolRangeValuesResponse> getPoolRangeValues() {
108 1 1. getPoolRangeValues : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getPoolRangeValues → SURVIVED
    return ResponseEntity.ok(poolService.getPoolRangeValues());
109
  }
110
111
  @GetMapping("/stake-pools-chart")
112
  @LogMessage
113
  @Operation(
114
      summary = "Get number of registered and active stake pools",
115
      tags = {"pools"})
116
  public ResponseEntity<StakePoolsChartResponse> getStakepoolsChart() {
117 1 1. getStakepoolsChart : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getStakepoolsChart → SURVIVED
    return ResponseEntity.ok(poolService.getStakePoolsChart());
118
  }
119
}

Mutations

60

1.1
Location : getDataForPoolRegistration
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getDataForPoolRegistration → SURVIVED

78

1.1
Location : getDataForPoolDeRegistration
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getDataForPoolDeRegistration → SURVIVED

97

1.1
Location : getTxPoolCertificatesHistory
Killed by : org.cardanofoundation.explorer.api.controller.PoolControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolControllerTest]/[method:testGetTxPoolCertificatesHistory()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getTxPoolCertificatesHistory → KILLED

108

1.1
Location : getPoolRangeValues
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getPoolRangeValues → SURVIVED

117

1.1
Location : getStakepoolsChart
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolController::getStakepoolsChart → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.14.2