DRepMapper.java

1
package org.cardanofoundation.explorer.api.mapper;
2
3
import java.util.Date;
4
5
import org.mapstruct.Mapper;
6
import org.mapstruct.Mapping;
7
8
import org.cardanofoundation.explorer.api.model.response.drep.DRepDelegatorsResponse;
9
import org.cardanofoundation.explorer.api.model.response.drep.DRepDetailsResponse;
10
import org.cardanofoundation.explorer.api.model.response.drep.DRepFilterResponse;
11
import org.cardanofoundation.explorer.api.model.response.drep.DRepRangeValuesResponse;
12
import org.cardanofoundation.explorer.api.projection.DRepDelegatorProjection;
13
import org.cardanofoundation.explorer.api.projection.DRepRangeProjection;
14
import org.cardanofoundation.explorer.common.entity.ledgersync.DRepInfo;
15
16
@Mapper(componentModel = "spring")
17
public interface DRepMapper {
18
  @Mapping(target = "createdAt", expression = "java(fromLong(dRepInfo.getCreatedAt()))")
19
  @Mapping(target = "votingParticipation", source = "govParticipationRate")
20
  DRepDetailsResponse fromDrepInfo(DRepInfo dRepInfo);
21
22
  @Mapping(
23
      target = "createdAt",
24
      expression = "java(fromLong(dRepDelegatorProjection.getBlockTime()))")
25
  DRepDelegatorsResponse fromDRepDelegatorProjection(
26
      DRepDelegatorProjection dRepDelegatorProjection);
27
28
  @Mapping(target = "createdAt", expression = "java(fromLong(dRepInfo.getCreatedAt()))")
29
  @Mapping(target = "updatedAt", expression = "java(fromLong(dRepInfo.getUpdatedAt()))")
30
  DRepFilterResponse fromDRepInfo(DRepInfo dRepInfo);
31
32
  DRepRangeValuesResponse fromDRepRangeProjection(DRepRangeProjection dRepRangeProjection);
33
34
  default Date fromLong(Long value) {
35 3 1. fromLong : replaced return value with null for org/cardanofoundation/explorer/api/mapper/DRepMapper::fromLong → SURVIVED
2. fromLong : Replaced long multiplication with division → SURVIVED
3. fromLong : negated conditional → KILLED
    return value == null ? null : new Date(value * 1000);
36
  }
37
}

Mutations

35

1.1
Location : fromLong
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/mapper/DRepMapper::fromLong → SURVIVED

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

3.3
Location : fromLong
Killed by : none
Replaced long multiplication with division → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.14.2