### Question:
PercentagePostingRule implements PostingRule<T> { @Override public void apply(T sourceEntry) { long targetAmount = (long) (sourceEntry.getAmount() * percentage); T targetEntry = sourceEntry.newInstance(targetAccount, targetAmount, sourceEntry.getWhenCreated(), sourceEntry.getWhenBooked()); SingleEntryTransaction<T> transaction = new SingleEntryTransaction<T>(targetEntry); transaction.commit(); } PercentagePostingRule(Account<T> targetAccount, double percentage); @Override void apply(T sourceEntry); @Override void reverse(T sourceEntry);  }### Answer:
@Test public void testApply() { Account<DefaultEntry> sourceAccount = new Account<DefaultEntry>(); Account<DefaultEntry> targetAccount = new Account<DefaultEntry>(); Account<DefaultEntry> memoAccount = new Account<DefaultEntry>(); testObject = new PercentagePostingRule<DefaultEntry>(memoAccount,0.9); targetAccount.addPostingRule(testObject); DefaultEntry sourceEntry = EntryFactory.INSTANCE.buildDefaultEntry(sourceAccount, -10L); DefaultEntry targetEntry = EntryFactory.INSTANCE.buildDefaultEntry(targetAccount, 10L); Transaction<DefaultEntry> transaction = new Transaction<DefaultEntry>(sourceEntry, targetEntry); transaction.commit(); assertThat(memoAccount.getBalance(), equalTo(9L)); }