PoolReportController.java

1
package org.cardanofoundation.explorer.api.controller;
2
3
import jakarta.validation.Valid;
4
5
import lombok.RequiredArgsConstructor;
6
7
import org.springframework.core.io.InputStreamResource;
8
import org.springframework.core.io.Resource;
9
import org.springframework.data.domain.Sort;
10
import org.springframework.http.HttpHeaders;
11
import org.springframework.http.MediaType;
12
import org.springframework.http.ResponseEntity;
13
import org.springframework.validation.annotation.Validated;
14
import org.springframework.web.bind.annotation.GetMapping;
15
import org.springframework.web.bind.annotation.PathVariable;
16
import org.springframework.web.bind.annotation.PostMapping;
17
import org.springframework.web.bind.annotation.RequestAttribute;
18
import org.springframework.web.bind.annotation.RequestBody;
19
import org.springframework.web.bind.annotation.RequestMapping;
20
import org.springframework.web.bind.annotation.RequestParam;
21
import org.springframework.web.bind.annotation.RestController;
22
23
import io.swagger.v3.oas.annotations.Operation;
24
import io.swagger.v3.oas.annotations.Parameter;
25
import io.swagger.v3.oas.annotations.tags.Tag;
26
import org.springdoc.core.annotations.ParameterObject;
27
28
import org.cardanofoundation.explorer.api.common.enumeration.ExportType;
29
import org.cardanofoundation.explorer.api.config.LogMessage;
30
import org.cardanofoundation.explorer.api.interceptor.auth.UserPrincipal;
31
import org.cardanofoundation.explorer.api.model.request.pool.report.PoolReportCreateRequest;
32
import org.cardanofoundation.explorer.api.model.request.stake.report.ReportHistoryFilterRequest;
33
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
34
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.DeRegistrationResponse;
35
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.PoolUpdateDetailResponse;
36
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.RewardResponse;
37
import org.cardanofoundation.explorer.api.model.response.pool.lifecycle.TabularRegisResponse;
38
import org.cardanofoundation.explorer.api.model.response.pool.report.PoolReportDetailResponse;
39
import org.cardanofoundation.explorer.api.model.response.pool.report.PoolReportExportResponse;
40
import org.cardanofoundation.explorer.api.model.response.pool.report.PoolReportListResponse;
41
import org.cardanofoundation.explorer.api.service.PoolReportService;
42
import org.cardanofoundation.explorer.common.entity.explorer.PoolReportHistory;
43
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
44
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
45
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
46
47
@RestController
48
@RequestMapping("api/v1/pool-report")
49
@RequiredArgsConstructor
50
@Validated
51
@Tag(name = "pool-report", description = "The pool lifecycle report APIs")
52
public class PoolReportController {
53
54
  private final PoolReportService poolReportService;
55
56
  @PostMapping("create")
57
  @LogMessage
58
  @Operation(
59
      summary = "Create report for pool lifecycle",
60
      tags = {"pool-report"})
61
  public ResponseEntity<Boolean> createPoolReport(
62
      @RequestBody PoolReportCreateRequest body,
63
      @RequestAttribute("user") UserPrincipal userPrincipal) {
64 1 1. createPoolReport : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::createPoolReport → KILLED
    return ResponseEntity.ok(poolReportService.create(body, userPrincipal));
65
  }
66
67
  @GetMapping("list")
68
  @LogMessage
69
  @Operation(
70
      summary = "Get list pool report by user",
71
      tags = {"pool-report"})
72
  public ResponseEntity<BaseFilterResponse<PoolReportListResponse>> listPoolReport(
73
      @RequestAttribute("user") UserPrincipal userPrincipal,
74
      @ParameterObject @Parameter(description = "filter condition")
75
          ReportHistoryFilterRequest filterRequest,
76
      @ParameterObject
77
          @PaginationValid
78
          @PaginationDefault(
79
              size = 20,
80
              sort = {"id"},
81
              direction = Sort.Direction.DESC)
82
          @Valid
83
          Pagination pagination) {
84 1 1. listPoolReport : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::listPoolReport → KILLED
    return ResponseEntity.ok(
85
        poolReportService.list(
86
            pagination.toPageable(), userPrincipal.getUsername(), filterRequest));
87
  }
88
89
  @GetMapping("detail/{reportId}/epoch-size")
90
  @LogMessage
91
  @Operation(
92
      summary = "Get epoch size of a pool report",
93
      tags = {"pool-report"})
94
  public ResponseEntity<BaseFilterResponse<PoolReportDetailResponse.EpochSize>>
95
      detailEpochSizePoolReport(
96
          @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
97
          @ParameterObject @PaginationValid @Valid Pagination pagination,
98
          @RequestAttribute("user") UserPrincipal userPrincipal) {
99 1 1. detailEpochSizePoolReport : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailEpochSizePoolReport → KILLED
    return ResponseEntity.ok(
100
        poolReportService.fetchEpochSize(
101
            reportId, pagination.toPageable(), userPrincipal.getUsername()));
102
  }
103
104
  @GetMapping("detail/{reportId}/export")
105
  @LogMessage
106
  @Operation(
107
      summary = "Export pool report",
108
      tags = {"pool-report"})
109
  public ResponseEntity<Resource> export(
110
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
111
      @RequestParam(required = false) @Parameter(description = "Type for export")
112
          ExportType exportType,
113
      @RequestAttribute("user") UserPrincipal userPrincipal) {
114
    PoolReportExportResponse response =
115
        poolReportService.export(reportId, exportType, userPrincipal.getUsername());
116 1 1. export : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::export → KILLED
    return ResponseEntity.ok()
117
        .contentLength(response.getByteArrayInputStream().available())
118
        .header(
119
            HttpHeaders.CONTENT_DISPOSITION,
120
            "attachment; filename=\"" + response.getFileName() + "\"")
121
        .contentType(MediaType.APPLICATION_OCTET_STREAM)
122
        .body(new InputStreamResource(response.getByteArrayInputStream()));
123
  }
124
125
  @GetMapping(value = "detail/{reportId}/pool-registration")
126
  @LogMessage
127
  @Operation(
128
      summary = "Get pool registration of a pool report",
129
      tags = {"pool-report"})
130
  public ResponseEntity<BaseFilterResponse<TabularRegisResponse>> detailPoolRegistration(
131
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
132
      @ParameterObject @PaginationValid @Valid Pagination pagination,
133
      @RequestAttribute("user") UserPrincipal userPrincipal) {
134 1 1. detailPoolRegistration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolRegistration → KILLED
    return ResponseEntity.ok(
135
        poolReportService.fetchPoolRegistration(
136
            reportId, pagination.toPageable(), userPrincipal.getUsername()));
137
  }
138
139
  @GetMapping(value = "detail/{reportId}/pool-update")
140
  @LogMessage
141
  @Operation(
142
      summary = "Get pool update of a pool report",
143
      tags = {"pool-report"})
144
  public ResponseEntity<BaseFilterResponse<PoolUpdateDetailResponse>> detailPoolUpdate(
145
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
146
      @ParameterObject @PaginationValid @Valid Pagination pagination,
147
      @RequestAttribute("user") UserPrincipal userPrincipal) {
148 1 1. detailPoolUpdate : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolUpdate → KILLED
    return ResponseEntity.ok(
149
        poolReportService.fetchPoolUpdate(
150
            reportId, pagination.toPageable(), userPrincipal.getUsername()));
151
  }
152
153
  @GetMapping(value = "detail/{reportId}/rewards-distribution")
154
  @LogMessage
155
  @Operation(
156
      summary = "Get rewards distribution of a pool report",
157
      tags = {"pool-report"})
158
  public ResponseEntity<BaseFilterResponse<RewardResponse>> detailRewardsDistribution(
159
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
160
      @ParameterObject @PaginationValid @Valid Pagination pagination,
161
      @RequestAttribute("user") UserPrincipal userPrincipal) {
162 1 1. detailRewardsDistribution : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailRewardsDistribution → KILLED
    return ResponseEntity.ok(
163
        poolReportService.fetchRewardsDistribution(
164
            reportId, pagination.toPageable(), userPrincipal.getUsername()));
165
  }
166
167
  @GetMapping(value = "detail/{reportId}/deregistration")
168
  @LogMessage
169
  @Operation(
170
      summary = "Get deregistration of a pool report",
171
      tags = {"pool-report"})
172
  public ResponseEntity<BaseFilterResponse<DeRegistrationResponse>> detailDeregistration(
173
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
174
      @ParameterObject @PaginationValid @Valid Pagination pagination,
175
      @RequestAttribute("user") UserPrincipal userPrincipal) {
176 1 1. detailDeregistration : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailDeregistration → KILLED
    return ResponseEntity.ok(
177
        poolReportService.fetchDeregistraion(
178
            reportId, pagination.toPageable(), userPrincipal.getUsername()));
179
  }
180
181
  @GetMapping("detail/{reportId}")
182
  @LogMessage
183
  @Operation(
184
      summary = "Get detail information of a pool report",
185
      tags = {"pool-report"})
186
  public ResponseEntity<PoolReportHistory> detailPoolReport(
187
      @PathVariable @Parameter(description = "The identifier of the report") Long reportId,
188
      @RequestAttribute("user") UserPrincipal userPrincipal) {
189 1 1. detailPoolReport : replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolReport → KILLED
    return ResponseEntity.ok(poolReportService.detail(reportId, userPrincipal.getUsername()));
190
  }
191
}

Mutations

64

1.1
Location : createPoolReport
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testCreatePoolReport()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::createPoolReport → KILLED

84

1.1
Location : listPoolReport
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testListPoolReport()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::listPoolReport → KILLED

99

1.1
Location : detailEpochSizePoolReport
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailEpochSizePoolReport()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailEpochSizePoolReport → KILLED

116

1.1
Location : export
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testExportExcelFile()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::export → KILLED

134

1.1
Location : detailPoolRegistration
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailPoolRegistration()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolRegistration → KILLED

148

1.1
Location : detailPoolUpdate
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailPoolUpdate()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolUpdate → KILLED

162

1.1
Location : detailRewardsDistribution
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailRewardsDistribution()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailRewardsDistribution → KILLED

176

1.1
Location : detailDeregistration
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailDeregistration()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailDeregistration → KILLED

189

1.1
Location : detailPoolReport
Killed by : org.cardanofoundation.explorer.api.controller.PoolReportControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.PoolReportControllerTest]/[method:testDetailPoolReport()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/PoolReportController::detailPoolReport → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2