### Question:
TransactionContextHelper { protected TransactionContext extractTransactionContext(Object[] args) { if (args != null && args.length > 0) { for (Object arg : args) { if (arg instanceof TransactionContext) { return (TransactionContext) arg; } if (arg instanceof TransactionContextProperties) { TransactionContextProperties transactionContextProperties = (TransactionContextProperties) arg; return new TransactionContext(transactionContextProperties.getGlobalTxId(), transactionContextProperties.getLocalTxId()); } } } return null; }    }### Answer:
@Test public void testExtractTransactionContext() { TransactionContext result = transactionContextHelper.extractTransactionContext(new Object[] {txContextProperties}); assertThat(result.globalTxId(), is(transactionGlobalTxId)); assertThat(result.localTxId(), is(transactionLocalTxId)); result = transactionContextHelper.extractTransactionContext(new Object[] {}); assertNull(result); result = transactionContextHelper.extractTransactionContext(null); assertNull(result); result = transactionContextHelper.extractTransactionContext(new Object[] {txContext}); assertThat(result, is(txContext)); TransactionContext otherTx = Mockito.mock(TransactionContext.class); result = transactionContextHelper.extractTransactionContext(new Object[] {otherTx, txContextProperties}); assertThat(result, is(otherTx)); }