TallyMessageBuilder { public final TallyMessage build() throws TallyMessageBuilderException { if (voucherDate == null) { throw new TallyMessageBuilderException("Voucher date is required before building"); } return new TallyMessage(voucherType, voucherDate, allLedgers); } TallyMessageBuilder(VoucherType voucherType, String branchName); final TallyMessageBuilder addCreditEntry(AccountingDto voucherEntry); final TallyMessageBuilder addDebitEntry(AccountingDto voucherEntry); final TallyMessageBuilder withVoucherDate(Date voucherDate); final TallyMessage build();  }
@Test(expected = TallyMessageBuilderException.class) public void testTallyMessageBuilderWithoutDate() throws TallyMessageBuilderException { new TallyMessageBuilder(VoucherType.JOURNAL, "branch").build(); }