### Question:
DexTransferMoneyTransaction extends DEX { @Override public void applyAttachment(Transaction tx, Account sender, Account recipient) { DexControlOfFrozenMoneyAttachment attachment = (DexControlOfFrozenMoneyAttachment) tx.getAttachment(); lookupAccountService().addToBalanceATM(sender, getLedgerEvent(), tx.getId(), -attachment.getOfferAmount()); lookupAccountService().addToBalanceAndUnconfirmedBalanceATM(recipient, getLedgerEvent(), tx.getId(), attachment.getOfferAmount()); DexService dexService = lookupDexService(); ExchangeContract dexContract = dexService.getDexContractById(attachment.getContractId()); long orderToClose = dexContract.getSender() == sender.getId() ? dexContract.getCounterOrderId() : dexContract.getOrderId(); dexService.closeOrder(orderToClose); }  @Override byte getSubtype(); @Override LedgerEvent getLedgerEvent(); @Override AbstractAttachment parseAttachment(ByteBuffer buffer); @Override AbstractAttachment parseAttachment(JSONObject attachmentData); @Override void validateAttachment(Transaction transaction); @Override boolean applyAttachmentUnconfirmed(Transaction transaction, Account senderAccount); @Override void applyAttachment(Transaction tx, Account sender, Account recipient); @Override void undoAttachmentUnconfirmed(Transaction transaction, Account senderAccount); @Override boolean isDuplicate(Transaction transaction, Map<TransactionType, Map<String, Integer>> duplicates); @Override boolean canHaveRecipient(); @Override boolean isPhasingSafe(); @Override String getName();  }### Answer:
@Test void testApplyAttachment() { Transaction tx = mock(Transaction.class); doReturn(attachment).when(tx).getAttachment(); doReturn(contract).when(dexService).getDexContractById(anyLong()); Account sender = mock(Account.class); Account recipient = mock(Account.class); doReturn(1000L).when(sender).getId(); doReturn(2000L).when(recipient).getId(); transactionType.applyAttachment(tx, sender, recipient); verify(transactionType.lookupAccountService()).addToBalanceATM(sender, LedgerEvent.DEX_TRANSFER_MONEY, 0, -100); verify(transactionType.lookupAccountService()).addToBalanceAndUnconfirmedBalanceATM(recipient, LedgerEvent.DEX_TRANSFER_MONEY, 0, 100); verify(dexService).closeOrder(300); }
@Test void testApplyAttachmentForContractRecipient() { Transaction tx = mock(Transaction.class); doReturn(attachment).when(tx).getAttachment(); doReturn(contract).when(dexService).getDexContractById(anyLong()); Account sender = mock(Account.class); Account recipient = mock(Account.class); doReturn(2000L).when(sender).getId(); doReturn(1000L).when(recipient).getId(); transactionType.applyAttachment(tx, sender, recipient); verify(transactionType.lookupAccountService()).addToBalanceATM(sender, LedgerEvent.DEX_TRANSFER_MONEY, 0, -100); verify(transactionType.lookupAccountService()).addToBalanceAndUnconfirmedBalanceATM(recipient, LedgerEvent.DEX_TRANSFER_MONEY, 0, 100); verify(dexService).closeOrder(200); }