@Test(groups = "fast") public void testGenerateEmptyInvoice() throws Exception { final Invoice invoice = Mockito.mock(Invoice.class); final String output = g.generateInvoice(createAccount(), invoice, false); Assert.assertNotNull(output); }
@Override @BeforeClass(groups = "fast") public void beforeClass() throws Exception { super.beforeClass(); final TranslatorConfig config = new ConfigurationObjectFactory(System.getProperties()).build(TranslatorConfig.class); final TemplateEngine templateEngine = new MustacheTemplateEngine(); final InvoiceFormatterFactory factory = new DefaultInvoiceFormatterFactory(); g = new HtmlInvoiceGenerator(factory, templateEngine, config, null); }
@Test(groups = "fast") public void testGenerateNullInvoice() throws Exception { final String output = g.generateInvoice(createAccount(), null, false); Assert.assertNull(output); }
@Test(groups = "fast") public void testGenerateInvoice() throws Exception { final String output = g.generateInvoice(createAccount(), createInvoice(), false); Assert.assertNotNull(output); }
@Override public String getInvoiceAsHTML(final UUID invoiceId, final TenantContext context) throws AccountApiException, IOException, InvoiceApiException { final Invoice invoice = getInvoice(invoiceId, context); if (invoice == null) { throw new InvoiceApiException(ErrorCode.INVOICE_NOT_FOUND, invoiceId); } final InternalTenantContext internalContext = internalCallContextFactory.createInternalTenantContext(invoiceId, ObjectType.INVOICE, context); final Account account = accountUserApi.getAccountById(invoice.getAccountId(), internalContext); // Check if this account has the MANUAL_PAY system tag boolean manualPay = false; final List<Tag> accountTags = tagApi.getTags(account.getId(), ObjectType.ACCOUNT, internalContext); for (final Tag tag : accountTags) { if (ControlTagType.MANUAL_PAY.getId().equals(tag.getTagDefinitionId())) { manualPay = true; break; } } return generator.generateInvoice(account, invoice, manualPay); }
htmlBody = generator.generateInvoice(account, invoice, manualPay); } catch (IOException e) { throw new InvoiceApiException(e, ErrorCode.EMAIL_SENDING_FAILED);