|
| 1 | +package com._4point.aem.docservices.rest_services.it_tests.client.output; |
| 2 | + |
| 3 | +import static com._4point.aem.docservices.rest_services.it_tests.TestUtils.*; |
| 4 | + |
| 5 | +import java.net.URL; |
| 6 | +import java.nio.file.Path; |
| 7 | +import java.nio.file.Paths; |
| 8 | +import java.util.Locale; |
| 9 | + |
| 10 | +import org.junit.jupiter.api.BeforeAll; |
| 11 | +import org.junit.jupiter.api.BeforeEach; |
| 12 | +import org.junit.jupiter.api.Disabled; |
| 13 | +import org.junit.jupiter.api.DisplayName; |
| 14 | +import org.junit.jupiter.api.Tag; |
| 15 | +import org.junit.jupiter.api.Test; |
| 16 | +import org.junit.jupiter.api.condition.EnabledIf; |
| 17 | +import org.junit.jupiter.api.condition.EnabledOnOs; |
| 18 | +import org.junit.jupiter.api.condition.OS; |
| 19 | + |
| 20 | +import com._4point.aem.docservices.rest_services.client.jersey.JerseyRestClient; |
| 21 | +import com._4point.aem.docservices.rest_services.client.output.RestServicesOutputServiceAdapter; |
| 22 | +import com._4point.aem.docservices.rest_services.it_tests.AemInstance; |
| 23 | +import com._4point.aem.docservices.rest_services.it_tests.TestUtils; |
| 24 | +import com._4point.aem.fluentforms.api.Document; |
| 25 | +import com._4point.aem.fluentforms.api.PathOrUrl; |
| 26 | +import com._4point.aem.fluentforms.api.output.OutputService; |
| 27 | +import com._4point.aem.fluentforms.api.output.PrintConfig; |
| 28 | +import com._4point.aem.fluentforms.impl.SimpleDocumentFactoryImpl; |
| 29 | +import com._4point.aem.fluentforms.impl.UsageContext; |
| 30 | +import com._4point.aem.fluentforms.impl.output.OutputServiceImpl; |
| 31 | +import com.adobe.fd.output.api.PaginationOverride; |
| 32 | + |
| 33 | +@Tag("client-tests") |
| 34 | +class GeneratePrintedOutputTest { |
| 35 | + |
| 36 | + private static final String CRX_CONTENT_ROOT = "crx:/content/dam/formsanddocuments/sample-forms"; |
| 37 | + |
| 38 | + private OutputService underTest; |
| 39 | + |
| 40 | + @BeforeAll |
| 41 | + static void setUpAll() throws Exception { |
| 42 | + AemInstance.AEM_1.prepareForTests(); |
| 43 | + } |
| 44 | + |
| 45 | + @BeforeEach |
| 46 | + void setUp() throws Exception { |
| 47 | + RestServicesOutputServiceAdapter adapter = RestServicesOutputServiceAdapter.builder(JerseyRestClient.factory()) |
| 48 | + .machineName(AemInstance.AEM_1.aemHost()) |
| 49 | + .port(AemInstance.AEM_1.aemPort()) |
| 50 | + .basicAuthentication(TEST_USER, TEST_USER_PASSWORD) |
| 51 | + .useSsl(false) |
| 52 | + .aemServerType(TEST_MACHINE_AEM_TYPE) |
| 53 | + .build(); |
| 54 | + |
| 55 | + underTest = new OutputServiceImpl(adapter, UsageContext.CLIENT_SIDE); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + @DisplayName("Test generatePrintedOutput() Just Form and Data.") |
| 60 | + void testgeneratePrintedOutput_JustFormAndData() throws Exception { |
| 61 | + Document pdfResult = underTest.generatePrintedOutput() |
| 62 | + .setPrintConfig(PrintConfig.HP_PCL_5e) |
| 63 | + .executeOn(REMOTE_SAMPLE_FORM_XDP, SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_DATA_XML)); |
| 64 | + |
| 65 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "generatePrintedOutput_JustFormAndData.pcl"); |
| 66 | + } |
| 67 | + |
| 68 | + @Test |
| 69 | + @DisplayName("Test generatePrintedOutput() Just Form Document and Data.") |
| 70 | + void testgeneratePrintedOutput_JustFormDocAndData() throws Exception { |
| 71 | + Document pdfResult = underTest.generatePrintedOutput() |
| 72 | + .setPrintConfig(PrintConfig.Generic_PS_L3) |
| 73 | + .executeOn(SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_XDP), SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_DATA_XML)); |
| 74 | + |
| 75 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "testgeneratePrintedOutput_JustFormDocAndData.ps"); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + @DisplayName("Test generatePrintedOutput() CRX Form and Data.") |
| 80 | + void testgeneratePrintedOutput_CRXFormAndData() throws Exception { |
| 81 | + Document pdfResult = underTest.generatePrintedOutput() |
| 82 | + .setPrintConfig(PrintConfig.ZPL600) |
| 83 | + .setContentRoot(PathOrUrl.from(CRX_CONTENT_ROOT)) |
| 84 | + .executeOn(REMOTE_SAMPLE_FORM_XDP.getFileName(), SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_DATA_XML)); |
| 85 | + |
| 86 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "generatePrintedOutput_CRXFormAndData.zpl"); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + @DisplayName("Test generatePrintedOutput() All Arguments.") |
| 91 | + void testgeneratePrintedOutput_AllArgs() throws Exception { |
| 92 | + Path contentRoot = REMOTE_SAMPLE_FORM_XDP.getParent(); |
| 93 | +// Path debugDir = null; |
| 94 | + |
| 95 | + Document pdfResult = underTest.generatePrintedOutput() |
| 96 | + .setContentRoot(contentRoot) |
| 97 | + .setCopies(2) |
| 98 | +// .setDebugDir(debugDir) |
| 99 | + .setLocale(Locale.CANADA_FRENCH) |
| 100 | + .setPaginationOverride(PaginationOverride.duplexShortEdge) |
| 101 | + .setPrintConfig(PrintConfig.HP_PCL_5e) |
| 102 | + .xci() |
| 103 | + .embedPclFonts(true) |
| 104 | + .done() |
| 105 | + // TODO: Since contentRoot is set, the full path should not be necessary. Try changing to just the filename. |
| 106 | + .executeOn(REMOTE_SAMPLE_FORM_XDP, SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_DATA_XML)); |
| 107 | + |
| 108 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "generatePrintedOutput_AllArgs.pcl"); |
| 109 | + } |
| 110 | + |
| 111 | + @Disabled("Sample artwork fails when sent as Document for some reason, but works when sent as a reference.") |
| 112 | + @Test |
| 113 | + @DisplayName("Test generatePrintedOutput() Just Form Doc. FluentFormsAPI Issue #15") |
| 114 | + void testgeneratePrintedOutput_JustFormDocIssue15() throws Exception { |
| 115 | + Document pdfResult = underTest.generatePrintedOutput() |
| 116 | + .setPrintConfig(PrintConfig.HP_PCL_5e) |
| 117 | + .executeOn(SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_ARTWORK_PDF)); |
| 118 | + |
| 119 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "generatePrintedOutput_JustFormDocIssue15.pcl"); |
| 120 | + } |
| 121 | + |
| 122 | + @Test |
| 123 | + @DisplayName("Test generatePrintedOutput() Just Form. FluentFormsAPI Issue #15") |
| 124 | + void testgeneratePrintedOutput_JustFormIssue15() throws Exception { |
| 125 | + Document pdfResult = underTest.generatePrintedOutput() |
| 126 | + .setPrintConfig(PrintConfig.Generic_PS_L3) |
| 127 | + .executeOn(REMOTE_SAMPLE_ARTWORK_PDF); |
| 128 | + |
| 129 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "testgeneratePrintedOutput_JustFormIssue15.ps"); |
| 130 | + } |
| 131 | + |
| 132 | + @Test |
| 133 | + @DisplayName("Test generatePrintedOutput() for issue #32.") |
| 134 | + void testgeneratePrintedOutput_MixedContentRoot_Issue32() throws Exception { |
| 135 | + Path contentRoot = REMOTE_SAMPLE_FORM_XDP.getParent().getParent(); // Get a content root two directories up |
| 136 | + Path template = REMOTE_SAMPLE_FORM_XDP.getParent().resolve(REMOTE_SAMPLE_FORM_XDP.getFileName()); // Get a template that contains a parent directory |
| 137 | + |
| 138 | + Document pdfResult = underTest.generatePrintedOutput() |
| 139 | + .setPrintConfig(PrintConfig.HP_PCL_5e) |
| 140 | + .setContentRoot(contentRoot) |
| 141 | + .executeOn(template, SimpleDocumentFactoryImpl.getFactory().create(LOCAL_SAMPLE_FORM_DATA_XML)); |
| 142 | + |
| 143 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "testgeneratePrintedOutput_MixedContentRoot_Issue32.pcl"); |
| 144 | + } |
| 145 | + |
| 146 | + |
| 147 | + @Test |
| 148 | + @EnabledOnOs(OS.WINDOWS) |
| 149 | + @EnabledIf("targetIsLinux") |
| 150 | + @DisplayName("Test generatePrintedOutput() Just Form with Linux Path. From Windows Machine") |
| 151 | + void testgeneratePrintedOutput_JustForm() throws Exception { |
| 152 | + URL formPath = new URL("file:/opt/adobe/ff_it_files/SampleForm.xdp"); |
| 153 | + Document pdfResult = underTest.generatePrintedOutput() |
| 154 | + .setPrintConfig(PrintConfig.HP_PCL_5e) |
| 155 | + .executeOn(formPath); |
| 156 | + |
| 157 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "testgeneratePrintedOutput_JustForm.pcl"); |
| 158 | + } |
| 159 | + |
| 160 | + @Test |
| 161 | + @EnabledOnOs(OS.WINDOWS) |
| 162 | + @EnabledIf("targetIsLinux") |
| 163 | + @DisplayName("Test generatePrintedOutput() Just Form with Linux ContentRoot. From Windows Machine") |
| 164 | + void testgeneratePrintedOutput_JustFormContentRoot() throws Exception { |
| 165 | + Path contentPath = Paths.get("\\","opt", "adobe", "ff_it_files"); |
| 166 | + Path formPath = Paths.get("SampleForm.xdp"); |
| 167 | + Document pdfResult = underTest.generatePrintedOutput() |
| 168 | + .setPrintConfig(PrintConfig.Generic_PS_L3) |
| 169 | + .setContentRoot(contentPath) |
| 170 | + .executeOn(formPath); |
| 171 | + |
| 172 | + TestUtils.validatePrintedResult(pdfResult.getInlineData(), "testgeneratePrintedOutput_JustFormContentRoot.ps"); |
| 173 | + } |
| 174 | + |
| 175 | + boolean targetIsLinux() { |
| 176 | + return AemInstance.AEM_1.isLinux(); |
| 177 | + } |
| 178 | +} |
0 commit comments