### Question:
ShardImporter { public void importLastShard(int height) { if (height == 0) { genesisImporter.importGenesisJson(false); } else { Shard completedShard = shardDao.getLastCompletedOrArchivedShard(); log.debug("Latest competed shard = {} for height = {}", completedShard, height); Long shardId = completedShard.getShardId(); ShardNameHelper nameHelper = new ShardNameHelper(); String shardFileId = nameHelper.getFullShardId(shardId, blockchainConfig.getChain().getChainId()); log.debug("Latest competed shard shardFileId = {}", shardFileId); ShardPresentData shardPresentData = new ShardPresentData(shardId, shardFileId, List.of()); importShard(shardPresentData, List.of("block", "transaction")); } } @Inject  ShardImporter(ShardDao shardDao, BlockchainConfig blockchainConfig, GenesisImporter genesisImporter, Blockchain blockchain, DerivedTablesRegistry derivedTablesRegistry, CsvImporter csvImporter, Zip zipComponent, DataTagDao dataTagDao, DownloadableFilesManager downloadableFilesManager, AplAppStatus aplAppStatus); void importShardByFileId(ShardPresentData shardPresentData); void importLastShard(int height); boolean canImport(int height); void importShard(ShardPresentData shardPresentData, List<String> excludedTables);  }### Answer:
@Test void importLastShardFailed() { assertThrows(NullPointerException.class, () -> shardImporter.importLastShard(-1)); }
@Test void testImportLastShardForZeroHeight() { doNothing().when(genesisImporter).importGenesisJson(false); shardImporter.importLastShard(0); verify(genesisImporter).importGenesisJson(false); verifyZeroInteractions(aplAppStatus, zipComponent, downloadableFilesManager, blockchain, blockchainConfig, blockchainProcessor); }
@Test void testImportLastShard() { doReturn(Paths.get("")).when(downloadableFilesManager).mapFileIdToLocalPath("shard::1;chain::" + chainId); doReturn(true).when(zipComponent).extract(Paths.get("").toAbsolutePath().toString(), csvImporter.getDataExportPath().toAbsolutePath().toString(), true); doNothing().when(genesisImporter).importGenesisJson(true); doReturn(List.of(ShardConstants.GOODS_TABLE_NAME, ShardConstants.PHASING_POLL_TABLE_NAME, ShardConstants.TAGGED_DATA_TABLE_NAME)).when(derivedTablesRegistry).getDerivedTableNames(); Shard lastShard = new Shard(1, 100); doReturn(lastShard).when(shardDao).getLastCompletedOrArchivedShard(); doReturn(lastShard).when(shardDao).getLastShard(); Chain chain = mock(Chain.class); doReturn(chainId).when(chain).getChainId(); doReturn(chain).when(blockchainConfig).getChain(); shardImporter.importLastShard(1); verify(aplAppStatus, times(6)).durableTaskUpdate(any(), anyString(), anyDouble()); verify(aplAppStatus).durableTaskFinished(null, false, "Shard data import"); }