TxController.java

1
package org.cardanofoundation.explorer.api.controller;
2
3
import java.util.List;
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.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.common.enumeration.TxChartRange;
24
import org.cardanofoundation.explorer.api.config.LogMessage;
25
import org.cardanofoundation.explorer.api.model.metadatastandard.bolnisi.CertDetailsData;
26
import org.cardanofoundation.explorer.api.model.metadatastandard.bolnisi.WineryData;
27
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
28
import org.cardanofoundation.explorer.api.model.response.TxFilterResponse;
29
import org.cardanofoundation.explorer.api.model.response.dashboard.TxGraph;
30
import org.cardanofoundation.explorer.api.model.response.dashboard.TxSummary;
31
import org.cardanofoundation.explorer.api.model.response.tx.TxResponse;
32
import org.cardanofoundation.explorer.api.service.BolnisiMetadataService;
33
import org.cardanofoundation.explorer.api.service.TxService;
34
import org.cardanofoundation.explorer.common.validation.length.LengthValid;
35
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
36
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
37
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
38
39
@RestController
40
@RequestMapping("/api/v1/txs")
41
@RequiredArgsConstructor
42
@Validated
43
@Tag(name = "transaction", description = "The transaction APIs")
44
public class TxController {
45
46
  private final TxService txService;
47
  private final BolnisiMetadataService bolnisiMetadataService;
48
49
  @GetMapping
50
  @LogMessage
51
  @Operation(summary = "Filter transaction")
52
  public ResponseEntity<BaseFilterResponse<TxFilterResponse>> filter(
53
      @ParameterObject
54
          @PaginationValid
55
          @PaginationDefault(
56
              size = 20,
57
              sort = {"blockId", "blockIndex"},
58
              direction = Sort.Direction.DESC)
59
          @Valid
60
          Pagination pagination) {
61 1 1. filter : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::filter → SURVIVED
    return ResponseEntity.ok(txService.getAll(pagination.toPageable()));
62
  }
63
64
  @GetMapping("/{hash}")
65
  @LogMessage
66
  @Operation(summary = "Get transaction detail by hash")
67
  public ResponseEntity<TxResponse> getTransactionDetail(
68
      @PathVariable
69
          @Parameter(description = "The hash identifier of the transaction.")
70
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
71
          String hash) {
72 1 1. getTransactionDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getTransactionDetail → SURVIVED
    return ResponseEntity.ok(txService.getTxDetailByHash(hash));
73
  }
74
75
  @GetMapping("/{hash}/{wineryId}")
76
  @LogMessage
77
  @Operation(summary = "Get winery data by tx hash detail")
78
  public ResponseEntity<WineryData> getWineryDataByTxHash(
79
      @PathVariable
80
          @Parameter(description = "The hash identifier of the transaction.")
81
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
82
          String hash,
83
      @PathVariable @Parameter(description = "The winery id") String wineryId) {
84 1 1. getWineryDataByTxHash : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getWineryDataByTxHash → NO_COVERAGE
    return ResponseEntity.ok(bolnisiMetadataService.getWineryData(hash, wineryId));
85
  }
86
87
  @GetMapping("/{hash}/certData/{certNo}")
88
  @LogMessage
89
  @Operation(summary = "Get certificate data by tx hash detail")
90
  public ResponseEntity<CertDetailsData> getCertDataByTxHash(
91
      @PathVariable
92
          @Parameter(description = "The hash identifier of the transaction.")
93
          @LengthValid(CommonConstant.TX_HASH_LENGTH)
94
          String hash,
95
      @PathVariable @Parameter(description = "The certificate number") String certNo) {
96 1 1. getCertDataByTxHash : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getCertDataByTxHash → NO_COVERAGE
    return ResponseEntity.ok(bolnisiMetadataService.getCertDetailsData(hash, certNo));
97
  }
98
99
  @GetMapping("/current")
100
  @LogMessage
101
  @Operation(summary = "Get current transactions")
102
  public ResponseEntity<List<TxSummary>> findCurrentTransaction() {
103 1 1. findCurrentTransaction : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::findCurrentTransaction → KILLED
    return ResponseEntity.ok(txService.findLatestTxSummary());
104
  }
105
106
  @GetMapping("/graph/{range}")
107
  @LogMessage
108
  @Operation(summary = "Get transaction chart (1M, 3M, 1Y, 3Y, MAX)")
109
  public ResponseEntity<List<TxGraph>> getTransactionChart(
110
      @PathVariable("range") @Parameter(description = "Type for chart") TxChartRange range) {
111 1 1. getTransactionChart : replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getTransactionChart → NO_COVERAGE
    return ResponseEntity.ok(txService.getTransactionChartByRange(range));
112
  }
113
}

Mutations

61

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

72

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

84

1.1
Location : getWineryDataByTxHash
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getWineryDataByTxHash → NO_COVERAGE

96

1.1
Location : getCertDataByTxHash
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getCertDataByTxHash → NO_COVERAGE

103

1.1
Location : findCurrentTransaction
Killed by : org.cardanofoundation.explorer.api.controller.TxControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.TxControllerTest]/[method:testFindCurrentTransaction_WhenTxServiceReturnsNoItems()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::findCurrentTransaction → KILLED

111

1.1
Location : getTransactionChart
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/controller/TxController::getTransactionChart → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.14.2