Search in sources :

Example 1 with RendererForFreemarker

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;
}
Also used : Field(java.lang.reflect.Field) FreeMarkerService(org.isisaddons.module.freemarker.dom.service.FreeMarkerService) RendererForFreemarker(org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker)

Example 2 with RendererForFreemarker

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");
}
Also used : Expectations(org.jmock.Expectations) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) RendererForFreemarker(org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker) Test(org.junit.Test)

Example 3 with RendererForFreemarker

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 ");
}
Also used : Expectations(org.jmock.Expectations) RendererForFreemarker(org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker) Test(org.junit.Test)

Aggregations

RendererForFreemarker (org.incode.module.docrendering.freemarker.dom.impl.RendererForFreemarker)3 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)1 FreeMarkerService (org.isisaddons.module.freemarker.dom.service.FreeMarkerService)1