AddressController.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.*;
11
12
import io.swagger.v3.oas.annotations.Operation;
13
import io.swagger.v3.oas.annotations.Parameter;
14
import io.swagger.v3.oas.annotations.tags.Tag;
15
import org.springdoc.core.annotations.ParameterObject;
16
17
import org.cardanofoundation.explorer.api.common.enumeration.AnalyticType;
18
import org.cardanofoundation.explorer.api.config.LogMessage;
19
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse;
20
import org.cardanofoundation.explorer.api.model.response.TxFilterResponse;
21
import org.cardanofoundation.explorer.api.model.response.address.AddressChartBalanceResponse;
22
import org.cardanofoundation.explorer.api.model.response.address.AddressResponse;
23
import org.cardanofoundation.explorer.api.model.response.token.TokenAddressResponse;
24
import org.cardanofoundation.explorer.api.service.AddressService;
25
import org.cardanofoundation.explorer.api.service.TxService;
26
import org.cardanofoundation.explorer.common.entity.ledgersyncsagg.AddressTxAmount_;
27
import org.cardanofoundation.explorer.common.validation.pagination.Pagination;
28
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault;
29
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid;
30
31
@RestController
32
@RequestMapping("/api/v1/addresses")
33
@RequiredArgsConstructor
34
@Validated
35
@Tag(name = "address", description = "The address APIs")
36
public class AddressController {
37
38
  private final AddressService addressService;
39
40
  private final TxService txService;
41
42
  @GetMapping("/{address}")
43
  @LogMessage
44
  @Operation(
45
      summary = "Get detail information of payment address",
46
      description =
47
          "Get detail information of payment address with balance, txs, token and check contract",
48
      tags = {"address"})
49
  public ResponseEntity<AddressResponse> getAddressDetail(
50
      @PathVariable
51
          @Parameter(
52
              description =
53
                  "The human readable encoding of the output address."
54
                      + " Will be Base58 for Byron era addresses and Bech32 for Shelley era.")
55
          String address) {
56 1 1. getAddressDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getAddressDetail → KILLED
    return ResponseEntity.ok(addressService.getAddressDetail(address));
57
  }
58
59
  @GetMapping("/analytics/{address}/{type}")
60
  @LogMessage
61
  @Operation(
62
      summary = "Get analytics of address",
63
      description = "Get analytics balance of address and time type",
64
      tags = {"address"})
65
  public ResponseEntity<AddressChartBalanceResponse> getAddressAnalytics(
66
      @PathVariable
67
          @Parameter(
68
              description =
69
                  "The human readable encoding of the output address."
70
                      + " Will be Base58 for Byron era addresses and Bech32 for Shelley era.")
71
          String address,
72
      @PathVariable @Parameter(description = "Type for analytics by time") AnalyticType type) {
73 1 1. getAddressAnalytics : replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getAddressAnalytics → KILLED
    return ResponseEntity.ok(addressService.getAddressAnalytics(address, type));
74
  }
75
76
  @GetMapping("/{address}/txs")
77
  @LogMessage
78
  @Operation(
79
      summary = "Get list transaction by address",
80
      tags = {"address"})
81
  public ResponseEntity<BaseFilterResponse<TxFilterResponse>> getTransactions(
82
      @PathVariable
83
          @Parameter(
84
              description =
85
                  "The human readable encoding of the output address."
86
                      + " Will be Base58 for Byron era addresses and Bech32 for Shelley era.")
87
          String address,
88
      @ParameterObject
89
          @PaginationDefault(
90
              size = 20,
91
              sort = {AddressTxAmount_.SLOT},
92
              direction = Sort.Direction.DESC)
93
          @PaginationValid
94
          @Valid
95
          Pagination pagination) {
96 1 1. getTransactions : replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getTransactions → NO_COVERAGE
    return ResponseEntity.ok(txService.getTransactionsByAddress(address, pagination.toPageable()));
97
  }
98
99
  @GetMapping("/{address}/tokens")
100
  @LogMessage
101
  @Operation(
102
      summary = "Get list token by address",
103
      description =
104
          "Get list token by address with search by display name, will return all token if display name is null or empty",
105
      tags = {"address"})
106
  public ResponseEntity<BaseFilterResponse<TokenAddressResponse>> getTokenByAddress(
107
      @PathVariable
108
          @Parameter(
109
              description =
110
                  "The human readable encoding of the output address."
111
                      + " Will be Base58 for Byron era addresses and Bech32 for Shelley era.")
112
          String address,
113
      @RequestParam(required = false) @Parameter(description = "Display name query for search")
114
          String displayName,
115
      @ParameterObject @PaginationValid @Valid Pagination pagination) {
116 1 1. getTokenByAddress : replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getTokenByAddress → KILLED
    return ResponseEntity.ok(
117
        addressService.getTokenByDisplayName(pagination.toPageable(), address, displayName));
118
  }
119
}

Mutations

56

1.1
Location : getAddressDetail
Killed by : org.cardanofoundation.explorer.api.controller.AddressControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.AddressControllerTest]/[method:testGetAddressDetail()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getAddressDetail → KILLED

73

1.1
Location : getAddressAnalytics
Killed by : org.cardanofoundation.explorer.api.controller.AddressControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.AddressControllerTest]/[method:testGetAddressAnalytics()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getAddressAnalytics → KILLED

96

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

116

1.1
Location : getTokenByAddress
Killed by : org.cardanofoundation.explorer.api.controller.AddressControllerTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.controller.AddressControllerTest]/[method:testGetTokenByAddress()]
replaced return value with null for org/cardanofoundation/explorer/api/controller/AddressController::getTokenByAddress → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2