BlockchainServiceImpl implements BlockchainService { @Override public synchronized <H extends Object, B extends Serializable> B get(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); P2PConnection connection = blockchain.getConnection(); Map<H, B> cache = unit.getCache(); boolean exists = cache.get(hash) != null; if (!exists) { B object = getDataFromDatabase(hash, unit); if (object == null) { object = requestData(hash, type, connection); } return object; } B result = cache.get(hash); return logger.traceExit(result); }  @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 testGetWithNullHashShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.get(null, blockchain, BlockchainUnitType.BLOCK); }
@Test(expected = IllegalArgumentException.class) public void testGetWithNullBlockchainShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.get("testHash", null, BlockchainUnitType.BLOCK); }