TallyMessageBuilder { public TallyMessageBuilder(VoucherType voucherType, String branchName) throws TallyMessageBuilderException { this.voucherType = voucherType; this.branchName = branchName; if (this.voucherType == null) { throw new TallyMessageBuilderException("Voucher type can not be null."); } if (this.branchName == null || branchName.equals("")) { throw new TallyMessageBuilderException("Branch name can not be empty."); } } TallyMessageBuilder(VoucherType voucherType, String branchName); final TallyMessageBuilder addCreditEntry(AccountingDto voucherEntry); final TallyMessageBuilder addDebitEntry(AccountingDto voucherEntry); final TallyMessageBuilder withVoucherDate(Date voucherDate); final TallyMessage build();  }
@Test public void testTallyMessageBuilder() throws TallyMessageBuilderException { AccountingDto voucherEntry = new AccountingDto("branch", "2010-04-20", "Payment", "4365", "GL CODE NAME", "4", "6"); new TallyMessageBuilder(VoucherType.JOURNAL, "branch").withVoucherDate(new Date()).addDebitEntry(voucherEntry) .addCreditEntry(voucherEntry).build(); }