BlockchainServiceImpl implements BlockchainService { @Override public synchronized <H extends Object, B extends Serializable> void put(H hash, B object, Blockchain blockchain, BlockchainUnitType type) throws IOException { boolean await = false; put(hash, object, blockchain, type, await); }  @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 testPutWithNullHashShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.put(null, "test", blockchain, BlockchainUnitType.BLOCK); }
@Test(expected = IllegalArgumentException.class) public void testPutWithNullObjectShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.put("testHash", null, blockchain, BlockchainUnitType.BLOCK); }
@Test(expected = IllegalArgumentException.class) public void testPutWithNullBlockchainShouldThrowExtension() throws IOException, ClassNotFoundException { blockchainService.put("testHash", "test", null, BlockchainUnitType.BLOCK); }
@Test public void testPut() throws IOException, ClassNotFoundException { String testHash = "testHash"; String testObject = "testObject"; Blockchain blockchain = new Blockchain(new BlockchainContext()); Assert.assertNull(blockchain.getUnit(BlockchainUnitType.BLOCK).getCache().get(testHash)); blockchainService.put(testHash, testObject, blockchain, BlockchainUnitType.BLOCK); Assert.assertNotNull(blockchain.getUnit(BlockchainUnitType.BLOCK).getCache().get(testHash)); String str = blockchainService.get(testHash, blockchain, BlockchainUnitType.BLOCK); Assert.assertNotNull(str); Assert.assertEquals(testObject, str); }