StakeKeyLifeCycleController.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.PathVariable;
14
import org.springframework.web.bind.annotation.RequestMapping;
15
import org.springframework.web.bind.annotation.RequestParam;
16
import org.springframework.web.bind.annotation.RestController;
17
18
import io.swagger.v3.oas.annotations.Operation;
19
import io.swagger.v3.oas.annotations.Parameter;
20
import io.swagger.v3.oas.annotations.tags.Tag;
21
import org.springdoc.core.annotations.ParameterObject;
22
23
import org.cardanofoundation.explorer.api.common.constant.CommonConstant;
24
import org.cardanofoundation.explorer.api.config.LogMessage;
25
import org.cardanofoundation.explorer.api.controller.validation.StakeKeyLengthValid;
26
import org.cardanofoundation.explorer.api.model.request.stake.StakeLifeCycleFilterRequest;
27
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
28
import org.cardanofoundation.explorer.api.model.response.stake.lifecycle.*;
29
import org.cardanofoundation.explorer.api.service.StakeKeyLifeCycleService;
30
import org.cardanofoundation.explorer.common.entity.enumeration.RewardType;
31
import org.cardanofoundation.explorer.common.entity.ledgersync.BaseEntity_;
32
import org.cardanofoundation.explorer.common.entity.ledgersync.Delegation_;
33
import org.cardanofoundation.explorer.common.entity.ledgersync.StakeRegistration_;
34
import org.cardanofoundation.explorer.common.entity.ledgersyncsagg.AddressTxAmount_;
35
import org.cardanofoundation.explorer.common.validation.date.DatePattern;
36
import org.cardanofoundation.explorer.common.validation.date.param.DateValid;
37
import org.cardanofoundation.explorer.common.validation.length.LengthValid;
38
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
39
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
40
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
41
import org.cardanofoundation.explorer.common.validation.prefixed.PrefixedValid;
42
43
@RestController
44
@RequestMapping("/api/v1/stake-lifecycle")
45
@RequiredArgsConstructor
46
@Validated
47
@Tag(name = "stake-lifecycle", description = "The stake key lifecycle APIs")
48
public class StakeKeyLifeCycleController {
49
50
  private final StakeKeyLifeCycleService stakeKeyLifeCycleService;
51
52
  @GetMapping("/{stakeKey}")
53
  @LogMessage
54
  @Operation(
55
      summary = "Check lifecycle of stake key",
56
      description =
57
          "Check stake key lifecycle contains: registration, de-registration, delegation, reward,  withdrawal",
58
      tags = {"stake-lifecycle"})
59
  public ResponseEntity<StakeLifecycleResponse> getStakeLifeCycle(
60
      @PathVariable
61
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
62
          @StakeKeyLengthValid
63
          @Parameter(description = "The Bech32 encoded version of the stake address.")
64
          String stakeKey) {
65 1 1. getStakeLifeCycle : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeLifeCycle → KILLED
    return ResponseEntity.ok(stakeKeyLifeCycleService.getStakeLifeCycle(stakeKey));
66
  }
67
68
  @GetMapping("/{stakeKey}/registrations")
69
  @LogMessage
70
  @Operation(
71
      summary = "Get list registration transaction of stake key",
72
      tags = {"stake-lifecycle"})
73
  public ResponseEntity<BaseFilterResponse<StakeRegistrationFilterResponse>> getStakeRegistrations(
74
      @PathVariable
75
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
76
          @StakeKeyLengthValid
77
          @Parameter(description = "The Bech32 encoded version of the stake address.")
78
          String stakeKey,
79
      @ParameterObject StakeLifeCycleFilterRequest condition,
80
      @ParameterObject
81
          @PaginationValid
82
          @PaginationDefault(
83
              size = 20,
84
              sort = {StakeRegistration_.TX},
85
              direction = Sort.Direction.DESC)
86
          @Valid
87
          Pagination pagination) {
88 1 1. getStakeRegistrations : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeRegistrations → KILLED
    return ResponseEntity.ok(
89
        stakeKeyLifeCycleService.getStakeRegistrations(
90
            stakeKey, condition, pagination.toPageable()));
91
  }
92
93
  @GetMapping("/{stakeKey}/registrations/{hash}")
94
  @LogMessage
95
  @Operation(
96
      summary = "Get stake key registration transaction detail",
97
      tags = {"stake-lifecycle"})
98
  public ResponseEntity<StakeRegistrationDetailResponse> getStakeRegistrationDetail(
99
      @PathVariable
100
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
101
          @StakeKeyLengthValid
102
          @Parameter(description = "The Bech32 encoded version of the stake address.")
103
          String stakeKey,
104
      @PathVariable
105
          @Parameter(description = "The hash identifier of the transaction.")
106
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
107
          String hash) {
108 1 1. getStakeRegistrationDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeRegistrationDetail → KILLED
    return ResponseEntity.ok(stakeKeyLifeCycleService.getStakeRegistrationDetail(stakeKey, hash));
109
  }
110
111
  @GetMapping("/{stakeKey}/de-registrations")
112
  @LogMessage
113
  @Operation(
114
      summary = "Get list de-registration transaction of stake key",
115
      tags = {"stake-lifecycle"})
116
  public ResponseEntity<BaseFilterResponse<StakeRegistrationFilterResponse>>
117
      getStakeDeRegistrations(
118
          @PathVariable
119
              @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
120
              @StakeKeyLengthValid
121
              @Parameter(description = "The Bech32 encoded version of the stake address.")
122
              String stakeKey,
123
          @ParameterObject StakeLifeCycleFilterRequest condition,
124
          @ParameterObject
125
              @PaginationValid
126
              @PaginationDefault(
127
                  size = 20,
128
                  sort = {StakeRegistration_.TX},
129
                  direction = Sort.Direction.DESC)
130
              @Valid
131
              Pagination pagination) {
132 1 1. getStakeDeRegistrations : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeDeRegistrations → KILLED
    return ResponseEntity.ok(
133
        stakeKeyLifeCycleService.getStakeDeRegistrations(
134
            stakeKey, condition, pagination.toPageable()));
135
  }
136
137
  @GetMapping("/{stakeKey}/de-registrations/{hash}")
138
  @LogMessage
139
  @Operation(
140
      summary = "Get stake key de-registration transaction detail",
141
      tags = {"stake-lifecycle"})
142
  public ResponseEntity<StakeRegistrationDetailResponse> getStakeDeRegistrationDetail(
143
      @PathVariable
144
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
145
          @StakeKeyLengthValid
146
          @Parameter(description = "The Bech32 encoded version of the stake address.")
147
          String stakeKey,
148
      @PathVariable
149
          @Parameter(description = "The hash identifier of the transaction.")
150
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
151
          String hash) {
152 1 1. getStakeDeRegistrationDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeDeRegistrationDetail → KILLED
    return ResponseEntity.ok(stakeKeyLifeCycleService.getStakeDeRegistrationDetail(stakeKey, hash));
153
  }
154
155
  @GetMapping("/{stakeKey}/delegations")
156
  @LogMessage
157
  @Operation(
158
      summary = "Get list delegation transaction of stake key",
159
      tags = {"stake-lifecycle"})
160
  public ResponseEntity<BaseFilterResponse<StakeDelegationFilterResponse>> getDelegations(
161
      @PathVariable
162
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
163
          @StakeKeyLengthValid
164
          @Parameter(description = "The Bech32 encoded version of the stake address.")
165
          String stakeKey,
166
      @ParameterObject StakeLifeCycleFilterRequest condition,
167
      @ParameterObject
168
          @PaginationValid
169
          @PaginationDefault(
170
              size = 20,
171
              sort = {Delegation_.TX},
172
              direction = Sort.Direction.DESC)
173
          @Valid
174
          Pagination pagination) {
175 1 1. getDelegations : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDelegations → KILLED
    return ResponseEntity.ok(
176
        stakeKeyLifeCycleService.getStakeDelegations(stakeKey, condition, pagination.toPageable()));
177
  }
178
179
  @GetMapping("/{stakeKey}/delegations/{hash}")
180
  @LogMessage
181
  @Operation(
182
      summary = "Get stake key delegation transaction detail",
183
      tags = {"stake-lifecycle"})
184
  public ResponseEntity<StakeDelegationDetailResponse> getDelegationDetail(
185
      @PathVariable
186
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
187
          @StakeKeyLengthValid
188
          @Parameter(description = "The Bech32 encoded version of the stake address.")
189
          String stakeKey,
190
      @PathVariable
191
          @Parameter(description = "The hash identifier of the transaction.")
192
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
193
          String hash) {
194 1 1. getDelegationDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDelegationDetail → KILLED
    return ResponseEntity.ok(stakeKeyLifeCycleService.getStakeDelegationDetail(stakeKey, hash));
195
  }
196
197
  @GetMapping("/{stakeKey}/rewards")
198
  @LogMessage
199
  @Operation(
200
      summary = "Get list reward of stake key",
201
      tags = {"stake-lifecycle"})
202
  public ResponseEntity<BaseFilterResponse<StakeRewardResponse>> getRewards(
203
      @PathVariable
204
          @Parameter(description = "The Bech32 encoded version of the stake address.")
205
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
206
          @StakeKeyLengthValid
207
          String stakeKey,
208
      @RequestParam(value = "type", required = false) RewardType type,
209
      @RequestParam(value = "fromDate", required = false)
210
          @DateValid(pattern = DatePattern.YYYY_MM_DD)
211
          Date fromDate,
212
      @RequestParam(value = "toDate", required = false) @DateValid(pattern = DatePattern.YYYY_MM_DD)
213
          Date toDate,
214
      @ParameterObject
215
          @PaginationValid
216
          @PaginationDefault(
217
              size = 20,
218
              sort = {BaseEntity_.ID},
219
              direction = Sort.Direction.DESC)
220
          @Valid
221
          Pagination pagination) {
222 1 1. getRewards : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getRewards → KILLED
    return ResponseEntity.ok(
223
        stakeKeyLifeCycleService.getStakeRewards(
224
            stakeKey, fromDate, toDate, type, pagination.toPageable()));
225
  }
226
227
  @GetMapping("/{stakeKey}/withdrawals")
228
  @LogMessage
229
  @Operation(
230
      summary = "Get list withdrawal transaction of stake key",
231
      tags = {"stake-lifecycle"})
232
  public ResponseEntity<BaseFilterResponse<StakeWithdrawalFilterResponse>> getWithdrawals(
233
      @PathVariable
234
          @Parameter(description = "The Bech32 encoded version of the stake address.")
235
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
236
          @StakeKeyLengthValid
237
          String stakeKey,
238
      @ParameterObject @Parameter(description = "filter condition")
239
          StakeLifeCycleFilterRequest condition,
240
      @ParameterObject
241
          @PaginationValid
242
          @PaginationDefault(
243
              size = 20,
244
              sort = {BaseEntity_.ID},
245
              direction = Sort.Direction.DESC)
246
          @Valid
247
          Pagination pagination) {
248 1 1. getWithdrawals : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getWithdrawals → KILLED
    return ResponseEntity.ok(
249
        stakeKeyLifeCycleService.getStakeWithdrawals(stakeKey, condition, pagination.toPageable()));
250
  }
251
252
  @GetMapping("/{stakeKey}/withdrawals/{hash}")
253
  @LogMessage
254
  @Operation(
255
      summary = "Get stake key withdrawal transaction detail",
256
      tags = {"stake-lifecycle"})
257
  public ResponseEntity<StakeWithdrawalDetailResponse> getDetailWithdrawal(
258
      @PathVariable
259
          @Parameter(description = "The Bech32 encoded version of the stake address.")
260
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
261
          @StakeKeyLengthValid
262
          String stakeKey,
263
      @PathVariable
264
          @Parameter(description = "The hash identifier of the transaction.")
265
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
266
          String hash) {
267 1 1. getDetailWithdrawal : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDetailWithdrawal → KILLED
    return ResponseEntity.ok(stakeKeyLifeCycleService.getStakeWithdrawalDetail(stakeKey, hash));
268
  }
269
270
  @GetMapping("/{stakeKey}/wallet-activity")
271
  @LogMessage
272
  @Operation(
273
      summary = "Get wallet activity of stake key",
274
      tags = {"stake-lifecycle"})
275
  public ResponseEntity<BaseFilterResponse<StakeWalletActivityResponse>> getWalletActivities(
276
      @PathVariable
277
          @Parameter(description = "The Bech32 encoded version of the stake address.")
278
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
279
          @StakeKeyLengthValid
280
          String stakeKey,
281
      @ParameterObject
282
          @PaginationValid
283
          @PaginationDefault(
284
              size = 20,
285
              sort = {AddressTxAmount_.BLOCK_TIME},
286
              direction = Sort.Direction.DESC)
287
          @Valid
288
          Pagination pagination) {
289 1 1. getWalletActivities : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getWalletActivities → KILLED
    return ResponseEntity.ok(
290
        stakeKeyLifeCycleService.getStakeWalletActivities(stakeKey, pagination.toPageable()));
291
  }
292
293
  @GetMapping("/{stakeKey}/reward-activity")
294
  @LogMessage
295
  @Operation(
296
      summary = "Get reward activity of stake key",
297
      tags = {"stake-lifecycle"})
298
  public ResponseEntity<BaseFilterResponse<StakeRewardActivityResponse>> getRewardActivities(
299
      @PathVariable
300
          @Parameter(description = "The Bech32 encoded version of the stake address.")
301
          @PrefixedValid(CommonConstant.PREFIXED_STAKE_KEY)
302
          @StakeKeyLengthValid
303
          String stakeKey,
304
      @ParameterObject
305
          @PaginationValid
306
          @PaginationDefault(
307
              size = 20,
308
              sort = {"time"},
309
              direction = Sort.Direction.DESC)
310
          @Valid
311
          Pagination pagination) {
312 1 1. getRewardActivities : replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getRewardActivities → KILLED
    return ResponseEntity.ok(
313
        stakeKeyLifeCycleService.getStakeRewardActivities(stakeKey, pagination.toPageable()));
314
  }
315
}

Mutations

65

1.1
Location : getStakeLifeCycle
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:testGetStakeLifeCycle()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeLifeCycle → KILLED

88

1.1
Location : getStakeRegistrations
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetRegistrations()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeRegistrations → KILLED

108

1.1
Location : getStakeRegistrationDetail
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetRegistrationDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeRegistrationDetail → KILLED

132

1.1
Location : getStakeDeRegistrations
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetDeRegistrations()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeDeRegistrations → KILLED

152

1.1
Location : getStakeDeRegistrationDetail
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetDeRegistrationDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getStakeDeRegistrationDetail → KILLED

175

1.1
Location : getDelegations
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetDelegations()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDelegations → KILLED

194

1.1
Location : getDelegationDetail
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetDelegationDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDelegationDetail → KILLED

222

1.1
Location : getRewards
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetRewards()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getRewards → KILLED

248

1.1
Location : getWithdrawals
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetWithdrawals()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getWithdrawals → KILLED

267

1.1
Location : getDetailWithdrawal
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:shouldGetWithdrawalDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getDetailWithdrawal → KILLED

289

1.1
Location : getWalletActivities
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:testGetWalletActivities()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getWalletActivities → KILLED

312

1.1
Location : getRewardActivities
Killed by : org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.StakeKeyLifeCycleControllerTest]/[method:testGetRewardActivities()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/StakeKeyLifeCycleController::getRewardActivities → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2