PoolLifecycleController.java

1
package org.cardanofoundation.explorer.api.controller;
2
3
import java.util.Date;
4
5
import jakarta.validation.Valid;
6
7
import lombok.RequiredArgsConstructor;
8
9
import org.springframework.data.domain.Sort;
10
import org.springframework.http.ResponseEntity;
11
import org.springframework.validation.annotation.Validated;
12
import org.springframework.web.bind.annotation.GetMapping;
13
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestParam;
15
import org.springframework.web.bind.annotation.RestController;
16
17
import io.swagger.v3.oas.annotations.Operation;
18
import io.swagger.v3.oas.annotations.Parameter;
19
import io.swagger.v3.oas.annotations.tags.Tag;
20
import org.springdoc.core.annotations.ParameterObject;
21
22
import org.cardanofoundation.explorer.api.common.constant.CommonConstant;
23
import org.cardanofoundation.explorer.api.config.LogMessage;
24
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
25
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.DeRegistrationResponse;
26
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.PoolInfoResponse;
27
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.PoolUpdateDetailResponse;
28
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.PoolUpdateResponse;
29
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.RegistrationResponse;
30
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.RewardResponse;
31
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.SPOStatusResponse;
32
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.TabularRegisResponse;
33
import org.cardanofoundation.explorer.api.service.PoolLifecycleService;
34
import org.cardanofoundation.explorer.common.validation.date.DatePattern;
35
import org.cardanofoundation.explorer.common.validation.date.param.DateValid;
36
import org.cardanofoundation.explorer.common.validation.length.LengthValid;
37
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
38
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
39
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
40
import org.cardanofoundation.explorer.common.validation.prefixed.PrefixedValid;
41
42
@RestController
43
@RequestMapping("/api/v1/pool-lifecycle")
44
@RequiredArgsConstructor
45
@Validated
46
@Tag(name = "pool-lifecycle", description = "The pool lifecycle APIs")
47
public class PoolLifecycleController {
48
49
  private final PoolLifecycleService poolLifecycleService;
50
51
  @GetMapping(value = "/registration")
52
  @LogMessage
53
  @Operation(
54
      summary = "Get pool registration list",
55
      tags = {"pool-lifecycle"})
56
  public ResponseEntity<BaseFilterResponse<PoolUpdateResponse>> registration(
57
      @ParameterObject
58
          @PaginationValid
59
          @PaginationDefault(
60
              sort = {"bk.time"},
61
              direction = Sort.Direction.DESC)
62
          @Valid
63
          Pagination pagination,
64
      @RequestParam("poolView")
65
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
66
          @Parameter(description = "The pool view")
67
          String poolViewOrHash,
68
      @RequestParam(value = "txHash", required = false)
69
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
70
          @Parameter(description = "The hash identifier of the transaction")
71
          String txHash,
72
      @RequestParam(value = "fromDate", required = false)
73
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
74
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
75
          Date fromDate,
76
      @RequestParam(value = "toDate", required = false)
77
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
78
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
79
          Date toDate) {
80 1 1. registration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::registration → SURVIVED
    return ResponseEntity.ok(
81
        poolLifecycleService.registration(
82
            poolViewOrHash, txHash, fromDate, toDate, pagination.toPageable()));
83
  }
84
85
  @GetMapping(value = "/registration-detail")
86
  @LogMessage
87
  @Operation(
88
      summary = "Get information detail for pool registration",
89
      tags = {"pool-lifecycle"})
90
  public ResponseEntity<RegistrationResponse> registrationDetail(
91
      @RequestParam("poolView") @LengthValid(CommonConstant.POOL_VIEW_LENGTH) String poolViewOrHash,
92
      @RequestParam("id") @Parameter(description = "Id of pool registration") Long id) {
93 1 1. registrationDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::registrationDetail → KILLED
    return ResponseEntity.ok(poolLifecycleService.registrationDetail(poolViewOrHash, id));
94
  }
95
96
  @GetMapping(value = "/pool-update")
97
  @LogMessage
98
  @Operation(
99
      summary = "Get pool update list",
100
      tags = {"pool-lifecycle"})
101
  public ResponseEntity<BaseFilterResponse<PoolUpdateResponse>> poolUpdate(
102
      @ParameterObject
103
          @PaginationValid
104
          @PaginationDefault(
105
              sort = {"bk.time"},
106
              direction = Sort.Direction.DESC)
107
          @Valid
108
          Pagination pagination,
109
      @RequestParam("poolView")
110
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
111
          @Parameter(description = "The pool view")
112
          String poolViewOrHash,
113
      @RequestParam(value = "txHash", required = false)
114
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
115
          @Parameter(description = "The hash identifier of the transaction")
116
          String txHash,
117
      @RequestParam(value = "fromDate", required = false)
118
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
119
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
120
          Date fromDate,
121
      @RequestParam(value = "toDate", required = false)
122
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
123
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
124
          Date toDate) {
125 1 1. poolUpdate : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolUpdate → SURVIVED
    return ResponseEntity.ok(
126
        poolLifecycleService.poolUpdate(
127
            poolViewOrHash, txHash, fromDate, toDate, pagination.toPageable()));
128
  }
129
130
  @GetMapping(value = "/pool-update-detail")
131
  @LogMessage
132
  @Operation(
133
      summary = "Get information detail for pool update",
134
      tags = {"pool-lifecycle"})
135
  public ResponseEntity<PoolUpdateDetailResponse> poolUpdate(
136
      @RequestParam("id") @Parameter(description = "Id of pool update") Long id) {
137 1 1. poolUpdate : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolUpdate → KILLED
    return ResponseEntity.ok(poolLifecycleService.poolUpdateDetail(id));
138
  }
139
140
  @GetMapping(value = "/reward")
141
  @LogMessage
142
  @Operation(
143
      summary = "Get pool reward list",
144
      tags = {"pool-lifecycle"})
145
  public ResponseEntity<BaseFilterResponse<RewardResponse>> reward(
146
      @RequestParam("poolView")
147
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
148
          @Parameter(description = "The pool view")
149
          String poolViewOrHash,
150
      @ParameterObject @PaginationValid @Valid Pagination pagination) {
151 1 1. reward : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::reward → KILLED
    return ResponseEntity.ok(
152
        poolLifecycleService.listReward(poolViewOrHash, pagination.toPageable()));
153
  }
154
155
  @GetMapping(value = "/de-registration")
156
  @LogMessage
157
  @Operation(
158
      summary = "Get pool de-registration list",
159
      tags = {"pool-lifecycle"})
160
  public ResponseEntity<BaseFilterResponse<DeRegistrationResponse>> deRegistration(
161
      @ParameterObject
162
          @PaginationValid
163
          @PaginationDefault(
164
              sort = {"bk.time"},
165
              direction = Sort.Direction.DESC)
166
          @Valid
167
          Pagination pagination,
168
      @RequestParam("poolView")
169
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
170
          @Parameter(description = "The pool view")
171
          String poolViewOrHash,
172
      @RequestParam(value = "txHash", required = false)
173
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
174
          @Parameter(description = "The hash identifier of the transaction")
175
          String txHash,
176
      @RequestParam(value = "fromDate", required = false)
177
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
178
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
179
          Date fromDate,
180
      @RequestParam(value = "toDate", required = false)
181
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
182
          @Parameter(description = "Filter from date (with format: yyyy/MM/dd)")
183
          Date toDate) {
184 1 1. deRegistration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::deRegistration → SURVIVED
    return ResponseEntity.ok(
185
        poolLifecycleService.deRegistration(
186
            poolViewOrHash, txHash, fromDate, toDate, pagination.toPageable()));
187
  }
188
189
  @GetMapping(value = "/owner")
190
  @LogMessage
191
  @Operation(
192
      summary = "Get pool owner list",
193
      tags = {"pool-lifecycle"})
194
  public ResponseEntity<BaseFilterResponse<String>> poolOwner(
195
      @RequestParam("stakeKey")
196
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
197
          @Parameter(description = "The view of stake address owner")
198
          String stakeKey,
199
      @ParameterObject @PaginationValid @Valid Pagination pagination) {
200 1 1. poolOwner : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolOwner → KILLED
    return ResponseEntity.ok(
201
        poolLifecycleService.getPoolViewByStakeKey(stakeKey, pagination.toPageable()));
202
  }
203
204
  @GetMapping(value = "/pool-info")
205
  @LogMessage
206
  @Operation(
207
      summary = "Get pool information",
208
      tags = {"pool-lifecycle"})
209
  public ResponseEntity<PoolInfoResponse> poolInfo(
210
      @RequestParam("poolView")
211
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
212
          @Parameter(description = "The pool view")
213
          String poolViewOrHash) {
214 1 1. poolInfo : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolInfo → KILLED
    return ResponseEntity.ok(poolLifecycleService.poolInfo(poolViewOrHash));
215
  }
216
217
  @GetMapping(value = "/registration-list")
218
  @LogMessage
219
  @Operation(
220
      summary = "Get pool registration list for tabular view",
221
      tags = {"pool-lifecycle"})
222
  public ResponseEntity<BaseFilterResponse<TabularRegisResponse>> registrationList(
223
      @RequestParam("poolView")
224
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
225
          @Parameter(description = "The pool view")
226
          String poolViewOrHash,
227
      @ParameterObject
228
          @PaginationValid
229
          @PaginationDefault(
230
              size = 10,
231
              page = 0,
232
              sort = {"bk.time"},
233
              direction = Sort.Direction.DESC)
234
          @Valid
235
          Pagination pagination) {
236 1 1. registrationList : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::registrationList → SURVIVED
    return ResponseEntity.ok(
237
        poolLifecycleService.registrationList(poolViewOrHash, pagination.toPageable()));
238
  }
239
240
  @GetMapping(value = "/pool-update-list")
241
  @LogMessage
242
  @Operation(
243
      summary = "Get pool update list for tabular view",
244
      tags = {"pool-lifecycle"})
245
  public ResponseEntity<BaseFilterResponse<PoolUpdateDetailResponse>> poolUpdate(
246
      @RequestParam("poolView")
247
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
248
          @Parameter(description = "The pool view")
249
          String poolViewOrHash,
250
      @ParameterObject
251
          @PaginationValid
252
          @PaginationDefault(
253
              size = 10,
254
              page = 0,
255
              sort = {"bk.time"},
256
              direction = Sort.Direction.DESC)
257
          @Valid
258
          Pagination pagination) {
259 1 1. poolUpdate : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolUpdate → SURVIVED
    return ResponseEntity.ok(
260
        poolLifecycleService.poolUpdateList(poolViewOrHash, pagination.toPageable()));
261
  }
262
263
  @GetMapping(value = "/status")
264
  @LogMessage
265
  @Operation(
266
      summary = "Get pool status",
267
      tags = {"pool-lifecycle"})
268
  public ResponseEntity<SPOStatusResponse> poolStatus(
269
      @RequestParam("poolView")
270
          @LengthValid(CommonConstant.POOL_VIEW_LENGTH)
271
          @Parameter(description = "The pool view")
272
          String poolViewOrHash) {
273 1 1. poolStatus : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolStatus → KILLED
    return ResponseEntity.ok(poolLifecycleService.poolLifecycleStatus(poolViewOrHash));
274
  }
275
}

Mutations

80

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

93

1.1
Location : registrationDetail
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallRegistrationDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::registrationDetail → KILLED

125

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

137

1.1
Location : poolUpdate
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallPoolUpdateDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolUpdate → KILLED

151

1.1
Location : reward
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallReward()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::reward → KILLED

184

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

200

1.1
Location : poolOwner
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallPoolOwner()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolOwner → KILLED

214

1.1
Location : poolInfo
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallPoolInfo()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolInfo → KILLED

236

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

259

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

273

1.1
Location : poolStatus
Killed by : org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolLifecycleControllerTest]/[method:whenCallPoolStatus()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolLifecycleController::poolStatus → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2