### Question:
PollingTransactionReceiptProcessor extends TransactionReceiptProcessor { @Override public TransactionReceipt waitForTransactionReceipt( String transactionHash) throws IOException, TransactionException { return getTransactionReceipt(transactionHash, sleepDuration, attempts); } PollingTransactionReceiptProcessor(Web3j web3j, long sleepDuration, int attempts); @Override TransactionReceipt waitForTransactionReceipt(
            String transactionHash);  }### Answer:
@Test public void returnsTransactionReceiptWhenItIsAvailableInstantly() throws Exception { TransactionReceipt transactionReceipt = new TransactionReceipt(); doReturn(requestReturning(response(transactionReceipt))) .when(web3j).ethGetTransactionReceipt(TRANSACTION_HASH); TransactionReceipt receipt = processor.waitForTransactionReceipt(TRANSACTION_HASH); assertThat(receipt, sameInstance(transactionReceipt)); }
@Test public void throwsTransactionExceptionWhenReceiptIsNotAvailableInTime() throws Exception { doReturn(requestReturning(response(null))) .when(web3j).ethGetTransactionReceipt(TRANSACTION_HASH); try { processor.waitForTransactionReceipt(TRANSACTION_HASH); fail("call should fail with TransactionException"); } catch (TransactionException e) { } }
@Test public void returnsTransactionReceiptWhenItIsAvailableInstantly() throws Exception { TransactionReceipt transactionReceipt = new TransactionReceipt(); doReturn(requestReturning(response(transactionReceipt))) .when(web3j).platonGetTransactionReceipt(TRANSACTION_HASH); TransactionReceipt receipt = processor.waitForTransactionReceipt(TRANSACTION_HASH); assertThat(receipt, sameInstance(transactionReceipt)); }
@Test public void throwsTransactionExceptionWhenReceiptIsNotAvailableInTime() throws Exception { doReturn(requestReturning(response(null))) .when(web3j).platonGetTransactionReceipt(TRANSACTION_HASH); try { processor.waitForTransactionReceipt(TRANSACTION_HASH); fail("call should fail with TransactionException"); } catch (TransactionException e) { } }