BlockchainServiceImpl implements BlockchainService { @Override public synchronized <H extends Object, B extends Serializable> boolean contains(H hash, Blockchain blockchain, BlockchainUnitType type) throws IOException, ClassNotFoundException { logger.traceEntry("params: {} {} {}", hash, blockchain, type); Util.check(hash != null, "hash!=null"); Util.check(blockchain != null, "blockchain!=null"); BlockchainPersistenceUnit<H, B> unit = blockchain.getUnit(type); Map<H, B> cache = unit.getCache(); if (cache.containsKey(hash)) { logger.trace("cache contains hash"); return logger.traceExit(true); } B block = getLocal(hash, blockchain, type); return logger.traceExit(block != null); }  @Override synchronized boolean contains(H hash, Blockchain blockchain, BlockchainUnitType type); synchronized void putAndWait(H hash, B object, Blockchain blockchain, BlockchainUnitType type); @Override synchronized void put(H hash, B object, Blockchain blockchain, BlockchainUnitType type); @Override synchronized void putLocal(H hash, B object, Blockchain blockchain, BlockchainUnitType type); @Override synchronized List<B> getAll(List<H> hashes, Blockchain blockchain, BlockchainUnitType type); @Override synchronized B get(H hash, Blockchain blockchain, BlockchainUnitType type); @Override synchronized B getLocal(H hash, Blockchain blockchain, BlockchainUnitType type);  }
@Test(expected = IllegalArgumentException.class) public void testContainsWithNullHashShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.contains(null, blockchain, BlockchainUnitType.BLOCK); }
@Test(expected = IllegalArgumentException.class) public void testContainsWithNullBlockchainShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.contains("testHash", null, BlockchainUnitType.BLOCK); }