diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java index e8b9823..7ed0ed2 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java @@ -12,7 +12,10 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold import static com.iqser.red.service.redaction.report.v1.server.utils.OsUtils.getTemporaryDirectory; import static org.mockito.Mockito.when; +import java.io.ByteArrayInputStream; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -25,6 +28,9 @@ import org.apache.commons.io.IOUtils; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; @@ -70,7 +76,7 @@ import lombok.SneakyThrows; @ExtendWith(SpringExtension.class) @EnableAutoConfiguration(exclude = {/*StorageAutoConfiguration.class,*/RabbitAutoConfiguration.class}) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ComponentScan(excludeFilters={@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value=StorageAutoConfiguration.class)}) +@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = StorageAutoConfiguration.class)}) public class RedactionReportIntegrationTest { @Autowired @@ -134,6 +140,7 @@ public class RedactionReportIntegrationTest { return testDossier; } + @Test @SneakyThrows public void testWordJustificationAppendixA1() { @@ -149,7 +156,6 @@ public class RedactionReportIntegrationTest { var wordTemplateResource = new ClassPathResource("templates/Justification Appendix A1.docx"); var imageResource = new ClassPathResource("files/exampleImage.jpg"); - var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}", "Aktive Substanz \n Test Return", "{{dossier.attribute.RapporteurMemberState}}", @@ -213,6 +219,42 @@ public class RedactionReportIntegrationTest { @SneakyThrows public void testWordIUCLIDFile() { + XWPFDocument doc = getIUCLIDFile(); + + List paragraphs = doc.getParagraphs(); + + Assertions.assertEquals(1, paragraphs.size()); + + ClassPathResource classPathResource = new ClassPathResource("expected/iuclid.txt"); + InputStream inputStream = classPathResource.getInputStream(); + List expectedContent = IOUtils.readLines(inputStream, "UTF-8"); + + List contentOfParagraphs = getContentOfParagraphs(paragraphs, true); + + Assertions.assertIterableEquals(contentOfParagraphs, expectedContent); + + try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/IUCLID_Template_justification.docx")) { + fileOutputStream.write(wordReportGenerationService.toByteArray(doc)); + } + } + + + private List getContentOfParagraphs(List paragraphs, boolean deleteCarriageReturns) { + + List res = new ArrayList<>(); + + for (XWPFParagraph paragraph : paragraphs) { + for (XWPFRun run : paragraph.getRuns()) { + String textOfRun = deleteCarriageReturns ? run.text().replaceAll("\\n", "") : run.text(); + res.add(textOfRun); + } + } + return res; + } + + + private XWPFDocument getIUCLIDFile() throws IOException { + Dossier dossier = prepareDossier(); FileModel fileStatus = FileModel.builder().filename("filename").build(); @@ -227,11 +269,11 @@ public class RedactionReportIntegrationTest { var placeholders = buildPlaceHolderModel(new HashMap<>(), Map.of("{{file.attribute.Path}}", "Path"), List.of()); wordReportGenerationService.generateWordReport(reportEntries, placeholders, "test", doc, fileStatus, dossier, true); - byte[] report = wordReportGenerationService.toByteArray(doc); - try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/IUCLID_Template_justification.docx")) { - fileOutputStream.write(report); - } + byte[] report = wordReportGenerationService.toByteArray(doc); + XWPFDocument newDoc = new XWPFDocument(new ByteArrayInputStream(report)); + + return newDoc; } @@ -275,7 +317,10 @@ public class RedactionReportIntegrationTest { FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build(); RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class); - List reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, new HashMap<>(), dossier.getDossierId()); + List reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, + legalBasisMapping, + new HashMap<>(), + dossier.getDossierId()); ClassPathResource templateResource = new ClassPathResource("templates/Seeds-NewJustificationForm.docx"); XWPFDocument doc = new XWPFDocument(templateResource.getInputStream()); @@ -342,7 +387,6 @@ public class RedactionReportIntegrationTest { Map mapOfEntityDisplayName = createEntityDisplayNames(redactionLog); List reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName, dossier.getDossierId()); - ClassPathResource templateResource = new ClassPathResource("templates/Excel Report.xlsx"); var placeholders = buildPlaceHolderModel(new HashMap<>(), new HashMap<>(), List.of()); @@ -385,7 +429,10 @@ public class RedactionReportIntegrationTest { excelTemplateReportGenerationService.generateExcelReport(reportEntries, placeholders, "test", writeWorkbook, "dossierName", fileModel, excelModel, false); RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class); - List reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, mapOfEntityDisplayName, dossier.getDossierId()); + List reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, + legalBasisMapping, + mapOfEntityDisplayName, + dossier.getDossierId()); FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build(); excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile, placeholders, diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/expected/iuclid.txt b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/expected/iuclid.txt new file mode 100644 index 0000000..fdafa62 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/expected/iuclid.txt @@ -0,0 +1,19 @@ +filename + + +Article 39(e)(1) and Article 39(e)(2) of Regulation (EC) No 178/2002 any other personal data except for + a. the name and address of the applicant; + b. the names of authors of published or publicly available studies supporting such requests; and the names of all participants and observers in meetings of the Scientific Committee and the Scientific Panels, their working groups and any other ad hoc group meeting on the subject matter. +and except for personal data (names and addresses) of individuals involved in testing on vertebrate studies or in obtaining toxicological information + +relates to: P9 Syngenta Crop Protection AG, P10 Syngenta Crop Protection AG, P10 Syngenta Crop Protection AG, P10 Regina Dorn, P10 +41 (61) 323 6358, P10 +41 (61) 323 6155, P10 regina.dorn@syngenta.com, P10 Syngenta Limited, P13 Syngenta Crop Protection AG, P13 Regina Dorn, P13 +41 (61) 323 6358, P13 +41 (61) 323 6155, P13 regina.dorn@syngenta.com, P13 Syngenta Crop Protection AG, P13 Patrick Gardinal, P13 Syngenta Crop Protection AG, P13 +41 (0) 61 323 60 51, P13 +41 (0) 61 323 61 55, P13 patrick.gardinal@syngenta.com, P21 Meyer, P21 Meyer, P21 Mostert, P22 Moster, P22 Hargeaves, P22 Sole, P22 Vargo, P22 Rezaaiyan, P22 Evans, P22 Hargreaves, P22 Sole, P22 Tribolet, P22 Tribolet, P22 Tribolet, P22 Hargreaves, P22 Sole, P22 Tribolet, P22 Tribolet, P22 Tribolet, P22 Vargo, P22 O’Loughlin, P22 Hazelette, P22 Fankhauser, P22 Fankhauser, P23 Biedermann, P23 Chang, P23 Khalil, P23 Wolf, P23 Gemrot, P23 Gemrot, P23 Hargeaves, P23 Sole, P23 Vargo, P23 Rezaaiyan, P23 Evans, P23 Hargreaves, P23 Sole, P24 Hargreaves, P24 Sole, P24 Vargo, P24 Hargeaves, P24 Sole, P24 Vargo, P24 Rezaaiyan, P24 Evans, P24 Hargreaves, P24 Sole, P24 Hargreaves, P24 Sole, P24 Vargo, P25 Doubovetzky, P25 Garrigue, P25 Garrigue, P25 Hargreaves, P26 Tribolet, P26 Tribolet, P26 Tribolet, P26 Vargo, P26 Meseguer, P28 Class, P28 Richter, P28 Miller, P28 Class, P28 Richter, P28 Giannone, P28 Giannone, P28 Benazeraf, P28 Giannone, P28 Richter, P28 Allen, P28 Richter, P28 Hargreaves, P29 Hargreaves, P29 Sole, P29 Robinson, P29 Hargreaves, P29 Sole, P29 Richardson, P29 Meseguer, P30 Robinson, P30 Wolf, P30 Tribolet, P30 Tribolet, P30 Richter, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Miller, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Class, P30 Richter, P30 Miller, P30 Richter, P30 Richter, P30 Richter, P30 Richter, P30 Richter, P30 Richter, P30 Allen, P30 Richter, P30 Richter, P30 Richter, P30 Richter, P30 Allen, P31 Hargreaves, P31 Hargreaves, P31 Hargreaves, P31 Hargreaves, P31 Robinson, P31 Sole, P31 Sole, P31 Richardson, P31 Meseguer, P31 Meseguer, P31 Hargreaves, P31 Hargreaves, P31 Sole, P31 Sole, P31 Meseguer, P31 Meseguer, P31 Robinson, P31 Robinson, P31 Wolf, P31 Wolf, P31 Tribolet, P31 Tribolet, P31 Richter, P31 Richter, P31 Richter, P31 Richter, P31 Meseguer, P31 Anon, P32 Hartnett, P32 Kale, P34 Glaza SM, P34 Schoch M, P34 Winkler G, P34 Matting E, P34 Glaza SM, P34 Holbert MS, P34 Glaza SM, P34 Glaza SM, P34 Marty JH, P34 Glaza SM, P34 Gehrke H, P36 Anon, P37 Fankhauser, P37 Fankhauser, P37 Chang, P37 Fankhauser, P37 Fankhauser, P37 Chang, P37 Hazelette, P37 Mastrocco, P38 Hertner, P38 Sokolowski, P38 Beilstein, P38 Wollny, P38 Strasser, P38 Bohnenberger, P39 Hertner, P39 Dony, P39 Ham, P39 Cifone, P39 Hertner, P39 Tisdell, P39 Tisdell, P40 O’Loughlin, P40 Khalil, P40 Lochry, P40 Gilles, P40 Lightkep, P41 Manton, P41 Argus Laboratories, P41 Lightkep, P41 Manton, P41 Ciba-Geigy laboratory, P41 Gilles, P41 Giknis, P41 Lightkep, P41 Lochry, P42 Charlton, P42 Laville, P42 Aït-Aïssa, P42 Dalton, P42 Mathias, P42 Tisdel, P42 Tisdel, P42 Grennlee, P42 Akkan, P45 Capps, P45 Brown, P45 Mücke, P77 Keller A, P77 Mamouni, P77 Mamouni, P77 Zbaerben&Nicoll ier, P77 Hein W., P77 Mamouni, P78 Mamouni, P78 Zbaerben&Nicoll ier, P78 Morgenroth U, P78 Zbaerben&Nicoll ier, P78 Clark A, P79 Clark A, P79 Fent, P79 Hein W., P79 Zbaerben&Nicoll ier, P79 Kitschmann P, P79 Fent, P80 Kitschmann, P80 Zbaerben&Nicoll ier, P80 Keller, P80 Mamouni, P80 Mamouni, P80 Mamouni, P81 Bond&Ha nd, P81 Bond&Ha nd, P81 Zbaerben&Nicoll ier, P82 Bond&Ha nd, P82 Zbaerben&Nicoll ier, P82 Zbaerben&Nicoll ier, P83 Zbaerben&Nicoll ier, P83 Fent, P83 Zbaerben&Nicoll ier, P84 Bond&Ha nd, P84 Mamouni, P84 Mamouni, P84 Mamouni, P85 Simmonds R, P85 Merritt, A, P85 Simmonds M, P85 Simmonds R, P85 Simmonds M, P85 Simmonds R, P85 Simmonds R, P85 Merritt, A, P86 Mamouni A., P86 Simmonds R, P86 Merritt, A, P86 Mamouni A, P86 Mamouni A, P86 Mamouni A, P86 Kitschmann, P87 Kitschmann P, P87 Hein W., P87 Purdy J., P87 Clark, P87 Morgenroth, P87 Kitschmann, P87 Keller, P87 Simmonds, P87 Simmonds, P87 Lucas, P87 Phaff, P87 Hein, P87 Clark, P87 Keller, P87 Simmonds, P87 Simmonds, P88 Kitschmann, P88 Mamouni, P88 Hein, P88 Nicollier, P88 Nicollier&Glänzel, P90 Clark, P90 Clark, P90 Lucas, P90 Lucas, P90 Lucas, P90 Keller, P90 Keller, P90 Kitschmann, P90 Kitschmann, P90 Kitschmann, P90 Morgenroth, P90 Phaff, P90 Hein, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P90 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Phaff, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Clark, P91 Lucas, P91 Simmonds, P91 Simmonds, P91 Simmonds, P91 Simmonds, P92 Keller, P92 Simmonds, P92 Simmonds, P92 Simmonds, P92 Simmonds, P92 Morgenroth, P92 Kitschmann, P92 Lucas, P92 Hein, P92 Kitschmann, P92 Lucas, P92 Kitschmann, P92 Simmonds, P92 Simmonds, P92 Kitschmann, P93 Simmonds, P93 Simmonds, P93 Simmonds, P93 Simmonds, P93 Phaff, P93 Clark, P93 Lucas, P93 Simmonds, P93 Simmonds, P93 Simmonds, P93 Simmonds, P93 Keller, P93 Simmonds, P93 Simmonds, P93 Simmonds, P93 Simmonds, P94 Nicollier, P94 Glänzel, P94 Mamouni, P94 Simmonds, P94 Morgenroth, P94 Kitschmann, P94 Lucas, P94 Hein, P94 Hein, P94 Simmonds, P94 Kitschmann, P94 Nicollier, P94 Glänzel, P94 Lucas, P94 Kitschmann, P95 Nicollier, P95 Glänzel, P95 Simmonds, P95 Simmonds, P95 Simmonds, P95 Simmonds, P95 Phaff, P95 Simmonds, P95 Simmonds, P95 Clark, P95 Lucas, P95 Simmonds, P95 Simmonds, P95 Simmonds, P95 Simmonds, P96 Keller, P96 Simmonds, P96 Simmonds, P96 Simmonds, P96 Simmonds, P96 Kitschmann, P96 Kitschmann, P96 Nicollier, P96 Kitschmann, P96 Lucas, P96 Hein, P96 Kitschmann, P96 Nicollier, P96 Lucas, P96 Kitschmann, P96 Nicollier, P97 Mamouni, P97 Nicollier, P97 Gl änzel, P97 Nicollier, P97 Gl änzel, P97 Nicollier, P97 Gl änzel, P97 Roohi, P97 Roohi, P97 Roohi, P98 Clark, P98 Lucas, P98 Luca, P98 Roohi, P98 Roohi, P98 Roohi, P98 Simmonds, P98 Simmonds, P98 Simmonds, P98 Simmonds, P99 Simmonds, P99 Simmonds, P99 Simmonds, P99 Hein, P99 Simmonds, P99 Mamouni, P99 Merritt, P99 Simmonds, P100 Merritt, P100 Simmonds, P102 Spare, W.C., P102 Ellgehausen, H., P103 Glänzel, A., P103 Nicollier, G., P103 Hein, W., P103 Mamouni, A., P103 Mamouni, P103 Voelkel, W, P104 Spare, W.C., P104 Mamouni, A., P104 Ulbrich, R., P104 Spare, W.C., P104 Voelkel, W, P105 Simmonds, M., P105 Burgess, M, P105 Simmonds, M., P105 Simmonds, M., P106 Spare, P106 MüllerKallert, P106 Plücken, P106 Spare, P106 MüllerKallert, P107 Plücken, P114 Zepp, P114 Cline, P116 Mamouni, P116 Mamouni, P116 Seyfried, P116 Seyfried, P119 Kitschmann, P126 Kitschmann, P128 Bomfim Pestana C., P128 Anas, P128 Beavers, J.B., P128 Beavers, J.B., P128 Anas, P128 Beavers, J.B., P128 Beavers, J.B., P128 Anas, P128 Beavers, J.B., P128 Beavers, J.B., P128 Anas, P128 Taliaferro, P128 Taylor, S., P128 Walton, H., P128 Taliaferro, P128 Taylor, S., P128 Walton, H., P129 Kaczor, M.H., P129 Miller V., P129 Taylor, S., P129 Priestley, S., P129 Schoch, M., P129 Glaza, S.M., P129 Kuhn, P129 O’Loughlin, P131 Buccafusco, P131 Sachsse & Ullmann, P131 Collins, P131 Spare, P131 Liedtke, P131 Collins, P131 Spare, P131 Liedtke, P131 Memmert, P131 Eckenstein, P131 Hoberg, P131 Hefner, P133 Gonzalez-Valero, P134 Engelhard, P134 Wesiak, P134 Neumann, P134 Nienstedt, P134 Nienstedt, P134 Nienstedt, P134 Nienstedt, P134 Candolfi, P134 Candolfi, P134 Candolfi, P134 Candolfi, P135 Wesiak, P135 Neumann, P135 Reber, P135 Großmann, P136 Müther J., P136 Friedrich S., P136 Friedrich S., P136 Friedrich S., P136 Friedrich S., P136 Friedrich S., P136 Friedrich S., P136 Friedrich S., P136 Forster A., P136 Pease G., P136 Milanesi F., P137 Klein O., P137 McCormac, P137 McCormac, P137 McCormac, P137 Friedrich, P137 Friedrich, P137 Friedrich, P137 McCormac, P137 McCormac, P137 Vinall, P137 Vinall, P137 Vinall, P138 Schulz, P138 Schulz, P138 Schulz, P138 Vinall, P138 Vinall, P138 Schulz, L, P138 Grade, R., P138 Grade, R., P138 Seyfried, P138 Hutcheson, P138 Seyfried, P138 Hutcheson, P139 Chetram & Schuster, P139 Chetram & Schuster, P139 Bramby-Gunary, P139 Bramby-Gunary, P140 Boutin, P140 Boutin, P140 Boutin, P141 R. Grade, P141 R.Grade, P141 R. Grade, P142 Wood, P142 Albuquerque, P143 Wood, P143 Wood, P143 Wood, P145 Albuquerque, R., P145 Grimm, P145 Funkenhaus & Giessing, P145 Wolf, C., P147 Wolf, P147 Funkenhaus & Giessing, P147 Grimm, P147 Mellanby, K, P147 Gurney, P158 Klein, P163 Boutin, P164 Boutin, P164 Bramby-Gunary J., P164 Boutin, P164 Bramby-Gunary, P165 Boutin, P165 Boutin, P170 Hein W., P170 Keller A, P170 Clark A, P170 Clark A, P171 Morgenroth U, P171 Kitschmann P, P171 Hein W., P171 Kitschmann, P174 Tessier, P174 Amic, P176 Rüegg, P176 Rüegg, P176 Schwab, P176 Schwab, P176 Cordingley, P176 Corbin, P176 Dupen, P184 Anon, P200 Hayes, T.B., P200 Spolyarich, N., P208 Meseguer, P208 Lochry, P210 Kitschmann + + +Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002) the manufacturing or production process, including the method and innovative aspects thereof, as well as other technical and industrial specifications inherent to that process or method, except for information which is relevant to the assessment of safety + +relates to: P9 $.Friedrich + + +Article 63(2)(d) of Regulation (EC) No 1107/2009 information on the complete composition of a plant protection product + +relates to: P54 null - non-readable content, P54 null - non-readable content, P54 null - non-readable content, P54 null - non-readable content, P54 null - non-readable content, P54 null - non-readable content, P55 null - non-readable content, P55 null - non-readable content, P55 null - non-readable content, P185 null - non-readable content