HexUtils.java

1
package org.cardanofoundation.explorer.api.util;
2
3
import java.nio.charset.StandardCharsets;
4
5
import org.apache.commons.codec.binary.Hex;
6
7
import org.cardanofoundation.explorer.common.utils.StringUtil;
8
9
public class HexUtils {
10
11
  private HexUtils() {
12
    throw new IllegalStateException("Utility class");
13
  }
14
15
  /**
16
   * Convert from hex to UTF-8
17
   *
18
   * @param hexString string hex
19
   * @return string UTF-8
20
   */
21
  public static String fromHex(String hexString, String fingerprint) {
22
    try {
23
      byte[] bytes = Hex.decodeHex(hexString.toCharArray());
24 1 1. fromHex : negated conditional → KILLED
      if (StringUtil.isUtf8(bytes)) {
25 1 1. fromHex : replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → KILLED
        return new String(bytes, StandardCharsets.UTF_8);
26
      }
27 1 1. fromHex : replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → NO_COVERAGE
      return fingerprint;
28
    } catch (Exception ex) {
29 1 1. fromHex : replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → KILLED
      return fingerprint;
30
    }
31
  }
32
}

Mutations

24

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

25

1.1
Location : fromHex
Killed by : org.cardanofoundation.explorer.api.service.AddressServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.AddressServiceTest]/[method:getTokenByDisplayName_withNotEmptyDisplayName()]
replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → KILLED

27

1.1
Location : fromHex
Killed by : none
replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → NO_COVERAGE

29

1.1
Location : fromHex
Killed by : org.cardanofoundation.explorer.api.service.ScriptServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.ScriptServiceTest]/[method:testGetNativeScriptHolders_thenReturn()]
replaced return value with "" for org/cardanofoundation/explorer/api/util/HexUtils::fromHex → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2