ScriptMapper.java

1
package org.cardanofoundation.explorer.api.mapper;
2
3
import java.util.HashSet;
4
import java.util.Set;
5
6
import org.springframework.util.CollectionUtils;
7
8
import org.mapstruct.Mapper;
9
import org.mapstruct.Mapping;
10
11
import org.cardanofoundation.explorer.api.common.enumeration.TxPurposeType;
12
import org.cardanofoundation.explorer.api.model.request.script.smartcontract.SmartContractFilterRequest;
13
import org.cardanofoundation.explorer.api.model.response.script.projection.SmartContractTxProjection;
14
import org.cardanofoundation.explorer.api.model.response.script.smartcontract.SmartContractFilterResponse;
15
import org.cardanofoundation.explorer.api.model.response.script.smartcontract.SmartContractTxResponse;
16
import org.cardanofoundation.explorer.common.entity.explorer.SmartContractInfo;
17
18
@Mapper(componentModel = "spring")
19
public interface ScriptMapper {
20
21
  SmartContractTxResponse fromSmartContractTxProjection(
22
      SmartContractTxProjection smartContractTxProjection);
23
24
  @Mapping(target = "txPurposes", expression = "java(getScriptTxPurpose(smartContractInfo))")
25
  @Mapping(target = "scriptVersion", source = "type")
26
  SmartContractFilterResponse fromSCInfoToSCFilterResponse(SmartContractInfo smartContractInfo);
27
28
  default Set<TxPurposeType> getScriptTxPurpose(SmartContractInfo smartContractInfo) {
29
    Set<TxPurposeType> scriptPurposeTypes = new HashSet<>();
30 1 1. getScriptTxPurpose : negated conditional → SURVIVED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptCert())) {
31
      scriptPurposeTypes.add(TxPurposeType.CERT);
32
    }
33 1 1. getScriptTxPurpose : negated conditional → KILLED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptMint())) {
34
      scriptPurposeTypes.add(TxPurposeType.MINT);
35
    }
36 1 1. getScriptTxPurpose : negated conditional → SURVIVED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptReward())) {
37
      scriptPurposeTypes.add(TxPurposeType.REWARD);
38
    }
39 1 1. getScriptTxPurpose : negated conditional → KILLED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptSpend())) {
40
      scriptPurposeTypes.add(TxPurposeType.SPEND);
41
    }
42 1 1. getScriptTxPurpose : negated conditional → KILLED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptVote())) {
43
      scriptPurposeTypes.add(TxPurposeType.VOTE);
44
    }
45 1 1. getScriptTxPurpose : negated conditional → SURVIVED
    if (Boolean.TRUE.equals(smartContractInfo.getIsScriptPropose())) {
46
      scriptPurposeTypes.add(TxPurposeType.PROPOSE);
47
    }
48 1 1. getScriptTxPurpose : replaced return value with Collections.emptySet for org/cardanofoundation/explorer/api/mapper/ScriptMapper::getScriptTxPurpose → KILLED
    return scriptPurposeTypes;
49
  }
50
51
  default void setScriptTxPurpose(SmartContractFilterRequest filterRequest) {
52 1 1. setScriptTxPurpose : negated conditional → KILLED
    if (!CollectionUtils.isEmpty(filterRequest.getTxPurpose())) {
53
      Set<TxPurposeType> txPurposeTypes = filterRequest.getTxPurpose();
54 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptNone → SURVIVED
      filterRequest.setIsScriptNone(txPurposeTypes.contains(TxPurposeType.NO_TX_PURPOSE));
55 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptAny → SURVIVED
      filterRequest.setIsScriptAny(txPurposeTypes.contains(TxPurposeType.ANY));
56 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptReward → SURVIVED
      filterRequest.setIsScriptReward(txPurposeTypes.contains(TxPurposeType.REWARD));
57 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptCert → SURVIVED
      filterRequest.setIsScriptCert(txPurposeTypes.contains(TxPurposeType.CERT));
58 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptSpend → SURVIVED
      filterRequest.setIsScriptSpend(txPurposeTypes.contains(TxPurposeType.SPEND));
59 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptMint → SURVIVED
      filterRequest.setIsScriptMint(txPurposeTypes.contains(TxPurposeType.MINT));
60 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptVote → SURVIVED
      filterRequest.setIsScriptVote(txPurposeTypes.contains(TxPurposeType.VOTE));
61 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptPropose → SURVIVED
      filterRequest.setIsScriptPropose(txPurposeTypes.contains(TxPurposeType.PROPOSE));
62
    } else {
63 1 1. setScriptTxPurpose : removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptAny → NO_COVERAGE
      filterRequest.setIsScriptAny(true);
64
    }
65
  }
66
}

Mutations

30

1.1
Location : getScriptTxPurpose
Killed by : none
negated conditional → SURVIVED

33

1.1
Location : getScriptTxPurpose
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetSmartContracts_withScriptVersionIsPlutusV3()]
negated conditional → KILLED

36

1.1
Location : getScriptTxPurpose
Killed by : none
negated conditional → SURVIVED

39

1.1
Location : getScriptTxPurpose
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetSmartContracts_withScriptVersionIsPlutusV3()]
negated conditional → KILLED

42

1.1
Location : getScriptTxPurpose
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetSmartContracts_withScriptVersionIsPlutusV3()]
negated conditional → KILLED

45

1.1
Location : getScriptTxPurpose
Killed by : none
negated conditional → SURVIVED

48

1.1
Location : getScriptTxPurpose
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetSmartContracts_withScriptVersionIsPlutusV3()]
replaced return value with Collections.emptySet for org/cardanofoundation/explorer/api/mapper/ScriptMapper::getScriptTxPurpose → KILLED

52

1.1
Location : setScriptTxPurpose
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetSmartContracts_withScriptVersionIsPlutusV3()]
negated conditional → KILLED

54

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptNone → SURVIVED

55

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptAny → SURVIVED

56

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptReward → SURVIVED

57

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptCert → SURVIVED

58

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptSpend → SURVIVED

59

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptMint → SURVIVED

60

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptVote → SURVIVED

61

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptPropose → SURVIVED

63

1.1
Location : setScriptTxPurpose
Killed by : none
removed call to org/cardanofoundation/explorer/api/model/request/script/smartcontract/SmartContractFilterRequest::setIsScriptAny → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.14.2