### Question:
FullImportBlockStep implements Consumer<Block> { @Override public void accept(final Block block) { final long blockNumber = block.getHeader().getNumber(); final String blockHash = block.getHash().toHexString(); final String shortHash = String.format( "%s..%s", blockHash.substring(0, 6), blockHash.substring(blockHash.length() - 4, blockHash.length())); final BlockImporter importer = protocolSchedule.getByBlockNumber(blockNumber).getBlockImporter(); if (!importer.importBlock(protocolContext, block, HeaderValidationMode.SKIP_DETACHED)) { throw new InvalidBlockException("Failed to import block", blockNumber, block.getHash()); } int peerCount = -1; if (ethContext != null && ethContext.getEthPeers().peerCount() >= 0) { peerCount = ethContext.getEthPeers().peerCount(); } if (blockNumber % 200 == 0) { LOG.info("Import reached block {} ({}), Peers: {}", blockNumber, shortHash, peerCount); } } FullImportBlockStep(
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final EthContext ethContext); @Override void accept(final Block block);  }### Answer:
@Test public void shouldImportBlock() { final Block block = gen.block(); when(blockImporter.importBlock(protocolContext, block, SKIP_DETACHED)).thenReturn(true); importBlocksStep.accept(block); verify(protocolSchedule).getByBlockNumber(block.getHeader().getNumber()); verify(blockImporter).importBlock(protocolContext, block, SKIP_DETACHED); }
@Test public void shouldThrowExceptionWhenValidationFails() { final Block block = gen.block(); when(blockImporter.importBlock(protocolContext, block, SKIP_DETACHED)).thenReturn(false); assertThatThrownBy(() -> importBlocksStep.accept(block)) .isInstanceOf(InvalidBlockException.class); }