WebSocketServiceImpl.java

1
package org.cardanofoundation.explorer.api.service.impl;
2
3
import lombok.RequiredArgsConstructor;
4
import lombok.extern.log4j.Log4j2;
5
6
import org.springframework.stereotype.Service;
7
8
import org.cardanofoundation.explorer.api.common.enumeration.WebSocketEventType;
9
import org.cardanofoundation.explorer.api.event.blocksync.BlockSyncInfo;
10
import org.cardanofoundation.explorer.api.event.blocksync.BlockSyncMessage;
11
import org.cardanofoundation.explorer.api.event.websocket.WebSocketMessage;
12
import org.cardanofoundation.explorer.api.repository.ledgersync.BlockRepository;
13
import org.cardanofoundation.explorer.api.service.EpochService;
14
import org.cardanofoundation.explorer.api.service.WebSocketService;
15
import org.cardanofoundation.explorer.common.entity.ledgersync.Block;
16
17
@Service
18
@RequiredArgsConstructor
19
@Log4j2
20
public class WebSocketServiceImpl implements WebSocketService {
21
22
  private final EpochService epochService;
23
  private final BlockRepository blockRepository;
24
25
  @Override
26
  public WebSocketMessage getCurrentBlockInfoMessage() {
27
    Block block = blockRepository.findCurrentBlockById();
28
    BlockSyncInfo blockSyncInfo =
29
        BlockSyncInfo.builder()
30
            .blockNo(block.getBlockNo())
31
            .blockHash(block.getHash())
32 2 1. getCurrentBlockInfoMessage : changed conditional boundary → SURVIVED
2. getCurrentBlockInfoMessage : negated conditional → KILLED
            .hasTx(block.getTxCount() > 0)
33
            .epochSummary(epochService.getCurrentEpochSummary())
34
            .build();
35 1 1. getCurrentBlockInfoMessage : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/WebSocketServiceImpl::getCurrentBlockInfoMessage → KILLED
    return WebSocketMessage.builder()
36
        .eventType(WebSocketEventType.BLOCK)
37
        .payload(blockSyncInfo)
38
        .build();
39
  }
40
41
  @Override
42
  public WebSocketMessage getBatchBlockInfoMessage(BlockSyncMessage blockSyncMessage) {
43
    BlockSyncInfo blockSyncInfo =
44
        BlockSyncInfo.builder()
45
            .blockNo(blockSyncMessage.getLastBlockNo())
46
            .blockHash(blockSyncMessage.getLastBlockHash())
47
            .hasTx(blockSyncMessage.isHasTx())
48
            .epochSummary(epochService.getCurrentEpochSummary())
49
            .build();
50 1 1. getBatchBlockInfoMessage : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/WebSocketServiceImpl::getBatchBlockInfoMessage → KILLED
    return WebSocketMessage.builder()
51
        .eventType(WebSocketEventType.BLOCK)
52
        .payload(blockSyncInfo)
53
        .build();
54
  }
55
}

Mutations

32

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

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

35

1.1
Location : getCurrentBlockInfoMessage
Killed by : org.cardanofoundation.explorer.api.service.WebSocketServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.WebSocketServiceTest]/[method:getCurrentBlockInfoMessage_shouldReturnResponse()]
replaced return value with null for org/cardanofoundation/explorer/api/service/impl/WebSocketServiceImpl::getCurrentBlockInfoMessage → KILLED

50

1.1
Location : getBatchBlockInfoMessage
Killed by : org.cardanofoundation.explorer.api.service.WebSocketServiceTest.[engine:junit-jupiter]/[class:org.cardanofoundation.explorer.api.service.WebSocketServiceTest]/[method:getBatchBlockInfoMessage_shouldReturnResponse()]
replaced return value with null for org/cardanofoundation/explorer/api/service/impl/WebSocketServiceImpl::getBatchBlockInfoMessage → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.2