use of org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker in project estatio by estatio.
the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs_Test method rendererForFreemarker.
private RendererForFreemarker rendererForFreemarker() throws NoSuchFieldException, IllegalAccessException {
final FreeMarkerService freeMarkerService = new FreeMarkerService();
final Field configurationServiceField = FreeMarkerService.class.getDeclaredField("configurationService");
configurationServiceField.setAccessible(true);
configurationServiceField.set(freeMarkerService, mockConfigurationService);
freeMarkerService.init(ImmutableMap.of());
final RendererForFreemarker renderer = new RendererForFreemarker();
final Field freeMarkerServiceField = RendererForFreemarker.class.getDeclaredField("freeMarkerService");
freeMarkerServiceField.setAccessible(true);
freeMarkerServiceField.set(renderer, freeMarkerService);
return renderer;
}
use of org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker in project estatio by estatio.
the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs_Test method when_primary_occupancy.
@Test
public void when_primary_occupancy() throws Exception {
// given
final Occupancy stubOccupancy = new Occupancy();
stubOccupancy.setUnit(stubUnit);
stubOccupancy.setBrand(stubBrand);
context.checking(new Expectations() {
{
allowing(mockLease).primaryOccupancy();
will(returnValue(Optional.of(stubOccupancy)));
}
});
// when
final Object rendererModel = rendererModelFactory.newRendererModel(mockDocumentTemplate, mockDocument);
// given
final RendererForFreemarker renderer = rendererForFreemarker();
// when
final String nameText = DocumentTypeAndTemplatesFSForInvoicesUsingSsrs.loadResource("InvoiceEmailCoverNoteSubjectLine.ftl");
final String rendered = renderer.renderCharsToChars(stubDocumentType, "", "/", 0L, nameText, rendererModel);
// then
Assertions.assertThat(rendered).isEqualTo("Invoice 2016-11-01, XXX XXX-123 Buyer-1 Brandino");
}
use of org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker in project estatio by estatio.
the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs_Test method when_no_primary_occupancy.
@Test
public void when_no_primary_occupancy() throws Exception {
// given
context.checking(new Expectations() {
{
allowing(mockLease).primaryOccupancy();
will(returnValue(Optional.empty()));
}
});
// when
final Object rendererModel = rendererModelFactory.newRendererModel(mockDocumentTemplate, mockDocument);
// given
final RendererForFreemarker renderer = rendererForFreemarker();
// when
final String nameText = DocumentTypeAndTemplatesFSForInvoicesUsingSsrs.loadResource("InvoiceEmailCoverNoteSubjectLine.ftl");
final String rendered = renderer.renderCharsToChars(stubDocumentType, "", "/", 0L, nameText, rendererModel);
// then
Assertions.assertThat(rendered).isEqualTo("Invoice 2016-11-01, XXX Buyer-1 ");
}
Aggregations