BaseFilterResponse.java

1
package org.cardanofoundation.explorer.api.model.response;
2
3
import java.io.Serializable;
4
import java.util.List;
5
6
import lombok.AllArgsConstructor;
7
import lombok.Builder;
8
import lombok.Getter;
9
import lombok.NoArgsConstructor;
10
import lombok.Setter;
11
12
import org.springframework.data.domain.Page;
13
import org.springframework.data.domain.PageImpl;
14
import org.springframework.data.domain.Pageable;
15
16
@Getter
17
@Setter
18
@AllArgsConstructor
19
@NoArgsConstructor
20 8 1. toString : replaced return value with "" for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::toString → NO_COVERAGE
2. currentPage : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::currentPage → NO_COVERAGE
3. build : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::build → NO_COVERAGE
4. data : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::data → NO_COVERAGE
5. totalItems : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalItems → NO_COVERAGE
6. totalPages : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalPages → NO_COVERAGE
7. builder : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::builder → NO_COVERAGE
8. isDataOverSize : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::isDataOverSize → NO_COVERAGE
@Builder
21
public class BaseFilterResponse<T> implements Serializable {
22
23 1 1. getData : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getData → KILLED
  private List<T> data;
24 1 1. getTotalItems : replaced long return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalItems → KILLED
  private long totalItems;
25 1 1. getTotalPages : replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalPages → KILLED
  private int totalPages;
26 1 1. getCurrentPage : replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getCurrentPage → SURVIVED
  private int currentPage;
27 2 1. getIsDataOverSize : replaced Boolean return with False for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED
2. getIsDataOverSize : replaced Boolean return with True for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED
  private Boolean isDataOverSize;
28
29
  public BaseFilterResponse(Page<T> page) {
30
    this.data = page.getContent();
31
    this.totalItems = page.getTotalElements();
32
    this.totalPages = page.getTotalPages();
33
    this.currentPage = page.getNumber();
34
  }
35
36
  public <S> BaseFilterResponse(Page<S> page, List<T> data) {
37
    this.data = data;
38
    this.totalItems = page.getTotalElements();
39
    this.totalPages = page.getTotalPages();
40
    this.currentPage = page.getNumber();
41
  }
42
43
  public <S> BaseFilterResponse(List<T> data, long totalItems) {
44
    this.data = data;
45
    this.totalItems = totalItems;
46
  }
47
48
  public <S> BaseFilterResponse(List<T> data, long totalItems, int totalPages, int currentPage) {
49
    this.data = data;
50
    this.totalItems = totalItems;
51
    this.totalPages = totalPages;
52
    this.currentPage = currentPage;
53
  }
54
55
  public BaseFilterResponse(Page<T> page, boolean isDataOverSize) {
56
    this.data = page.getContent();
57
    this.totalItems = page.getTotalElements();
58
    this.totalPages = page.getTotalPages();
59
    this.currentPage = page.getNumber();
60
    this.isDataOverSize = isDataOverSize;
61
  }
62
63
  public static <T> Page<T> getPageImpl(List<T> lst, Pageable pageable) {
64
    final int start = (int) pageable.getOffset();
65 1 1. getPageImpl : Replaced integer addition with subtraction → KILLED
    final int end = Math.min((start + pageable.getPageSize()), lst.size());
66 2 1. getPageImpl : changed conditional boundary → SURVIVED
2. getPageImpl : negated conditional → KILLED
    if (start > lst.size()) {
67 1 1. getPageImpl : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → NO_COVERAGE
      return Page.empty();
68
    }
69 1 1. getPageImpl : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → KILLED
    return new PageImpl<>(lst.subList(start, end), pageable, lst.size());
70
  }
71
}

Mutations

20

1.1
Location : toString
Killed by : none
replaced return value with "" for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::toString → NO_COVERAGE

2.2
Location : currentPage
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::currentPage → NO_COVERAGE

3.3
Location : build
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::build → NO_COVERAGE

4.4
Location : data
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::data → NO_COVERAGE

5.5
Location : totalItems
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalItems → NO_COVERAGE

6.6
Location : totalPages
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalPages → NO_COVERAGE

7.7
Location : builder
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::builder → NO_COVERAGE

8.8
Location : isDataOverSize
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::isDataOverSize → NO_COVERAGE

23

1.1
Location : getData
Killed by : org.cardanofoundation.explorer.api.service.StakeKeyLifeCycleServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.StakeKeyLifeCycleServiceTest]/[method:whenStakeAddressDoNotHaveRewardsAvailable_showReturnRewardNotAvailable()]
replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getData → KILLED

24

1.1
Location : getTotalItems
Killed by : org.cardanofoundation.explorer.api.service.PoolLifecycleServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.PoolLifecycleServiceTest]/[method:whenStakeKeyIsExist_returnPoolViewList()]
replaced long return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalItems → KILLED

25

1.1
Location : getTotalPages
Killed by : org.cardanofoundation.explorer.api.service.StakeKeyServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.StakeKeyServiceTest]/[method:testGetWithdrawalHistories_thenReturn()]
replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalPages → KILLED

26

1.1
Location : getCurrentPage
Killed by : none
replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getCurrentPage → SURVIVED

27

1.1
Location : getIsDataOverSize
Killed by : none
replaced Boolean return with False for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED

2.2
Location : getIsDataOverSize
Killed by : none
replaced Boolean return with True for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED

65

1.1
Location : getPageImpl
Killed by : org.cardanofoundation.explorer.api.service.GovActionServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.GovActionServiceTest]/[method:testGetAuthorsByAnchor()]
Replaced integer addition with subtraction → KILLED

66

1.1
Location : getPageImpl
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : getPageImpl
Killed by : org.cardanofoundation.explorer.api.service.GovActionServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.GovActionServiceTest]/[method:testGetAuthorsByAnchor()]
negated conditional → KILLED

67

1.1
Location : getPageImpl
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → NO_COVERAGE

69

1.1
Location : getPageImpl
Killed by : org.cardanofoundation.explorer.api.service.GovActionServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.GovActionServiceTest]/[method:testGetAuthorsByAnchor()]
replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2