@Test
public void testPdfConfigValuesInTemplateOverrideValuesInConfig() throws Exception {
final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config-template-override-config.yaml"));
final Template rawTemplate = config.getTemplate("main");
final PDFConfig pdfConfigSpy = Mockito.spy(rawTemplate.getPdfConfig());
Template templateSpy = Mockito.spy(rawTemplate);
Mockito.when(templateSpy.getPdfConfig()).thenReturn(pdfConfigSpy);
final Map<String, Template> templates = config.getTemplates();
templates.put("main", templateSpy);
config.setTemplates(templates);
PJsonObject requestData = loadJsonRequestData();
OutputStream outputStream = new ByteArrayOutputStream();
OutputFormat format = this.outputFormat.get("pdfOutputFormat");
format.print(requestData, config,
getFile(JasperReportPDFOutputFormatTest.class, BASE_DIR), getTaskDirectory(),
outputStream);
assertAllMethodsCalled(pdfConfigSpy);
assertEquals(false, pdfConfigSpy.isCompressed());
assertEquals("Template Author", pdfConfigSpy.getAuthor());
assertEquals("Config Creator", pdfConfigSpy.getCreator());
assertEquals("Config Keywords", pdfConfigSpy.getKeywordsAsString());
assertEquals("Template Title", pdfConfigSpy.getTitle());
assertEquals("Config Subject", pdfConfigSpy.getSubject());
}