RED-4510: Generated Redaction Log and Generating will not run with profile
This commit is contained in:
parent
5834e8891f
commit
e1b8f5b89a
@ -113,7 +113,9 @@ public class RulesTest {
|
|||||||
private static final String IMPORTED_REDACTION = "imported_redaction";
|
private static final String IMPORTED_REDACTION = "imported_redaction";
|
||||||
private static final String PII = "PII";
|
private static final String PII = "PII";
|
||||||
private static final String RESOURCES_PATH = "src/test/resources/";
|
private static final String RESOURCES_PATH = "src/test/resources/";
|
||||||
private static final String REDACTION_LOG_PATH = RESOURCES_PATH + "RedactionLog/";
|
|
||||||
|
private static final String REDACTION_LOG_PATH = "RedactionLog/";
|
||||||
|
private static final String REDACTION_LOG_RESOURCES_PATH = RESOURCES_PATH + REDACTION_LOG_PATH;
|
||||||
private final static String TEST_DOSSIER_TEMPLATE_ID = "123";
|
private final static String TEST_DOSSIER_TEMPLATE_ID = "123";
|
||||||
private final static String TEST_DOSSIER_ID = "123";
|
private final static String TEST_DOSSIER_ID = "123";
|
||||||
private String TEST_FILE_ID = "123";
|
private String TEST_FILE_ID = "123";
|
||||||
@ -195,7 +197,7 @@ public class RulesTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates RedactionLog for given file and saves it here: REDACTION_LOG_PATH.
|
* Generates RedactionLog for given file and saves it here: REDACTION_LOG_PATH.
|
||||||
* If the RedactionLog already exists, the generating will be skipped
|
* If the RedactionLog already exists, it will be overwritten
|
||||||
* Test is ignored, because it's for manual tests.
|
* Test is ignored, because it's for manual tests.
|
||||||
*/
|
*/
|
||||||
@Ignore
|
@Ignore
|
||||||
@ -203,7 +205,7 @@ public class RulesTest {
|
|||||||
public void generateRedactionLogForOneFile() {
|
public void generateRedactionLogForOneFile() {
|
||||||
|
|
||||||
String fileName = "files/Compounds/31 A14111B - EU AIR3 - MCP Section 1 - Identity of the plant protection product.pdf";
|
String fileName = "files/Compounds/31 A14111B - EU AIR3 - MCP Section 1 - Identity of the plant protection product.pdf";
|
||||||
generateAndSaveRedactionLog(fileName);
|
generateAndSaveRedactionLog(fileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -221,6 +223,9 @@ public class RulesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyses file and compares its RedactionLog with saved one from here: REDACTION_LOG_PATH.
|
* Analyses file and compares its RedactionLog with saved one from here: REDACTION_LOG_PATH.
|
||||||
* If RedactionLog Json does not exist, test will fail.
|
* If RedactionLog Json does not exist, test will fail.
|
||||||
@ -249,10 +254,22 @@ public class RulesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@Test
|
||||||
private void generateAndSaveRedactionLog(String fileName) {
|
@Ignore
|
||||||
|
public void foo() {
|
||||||
|
String fileName = "oo-home/local-working-dir/3080193/RED-REDACTIONSERVICENIGHT0-JOB1/redaction-service-v1/redaction-service-server-v1/src/test/resources/files/Compounds/26 A8637C - EU AIR3 - LCP Section 10 - Ecotoxicological studies on the plant protection product - Reference list.pdf";
|
||||||
|
loadSavedRedactionLog(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
if (doesRedactionLogExist(fileName)) {
|
|
||||||
|
private void generateAndSaveRedactionLog(String fileName) {
|
||||||
|
generateAndSaveRedactionLog(fileName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private void generateAndSaveRedactionLog(String fileName, boolean force) {
|
||||||
|
|
||||||
|
if (!force && doesRedactionLogExist(fileName)) {
|
||||||
System.out.println("Skip generating RedactionLog as Json for " + fileName + " because it already exists.");
|
System.out.println("Skip generating RedactionLog as Json for " + fileName + " because it already exists.");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -398,7 +415,7 @@ public class RulesTest {
|
|||||||
private boolean doesRedactionLogExist(String pdfFileName) {
|
private boolean doesRedactionLogExist(String pdfFileName) {
|
||||||
|
|
||||||
File pdfFile = new File(pdfFileName);
|
File pdfFile = new File(pdfFileName);
|
||||||
String directory = REDACTION_LOG_PATH + pdfFile.getParentFile().getPath();
|
String directory = REDACTION_LOG_RESOURCES_PATH + pdfFile.getParentFile().getPath();
|
||||||
String fileName = StringUtils.replace(pdfFile.getName(), ".pdf", ".json");
|
String fileName = StringUtils.replace(pdfFile.getName(), ".pdf", ".json");
|
||||||
File file = new File(directory, fileName);
|
File file = new File(directory, fileName);
|
||||||
return file.exists();
|
return file.exists();
|
||||||
@ -420,7 +437,7 @@ public class RulesTest {
|
|||||||
|
|
||||||
File pdfFile = new File(pdfFileName);
|
File pdfFile = new File(pdfFileName);
|
||||||
|
|
||||||
String directory = REDACTION_LOG_PATH + pdfFile.getParentFile().getPath();
|
String directory = REDACTION_LOG_RESOURCES_PATH + pdfFile.getParentFile().getPath();
|
||||||
File dr = new File(directory);
|
File dr = new File(directory);
|
||||||
boolean created = dr.mkdirs();
|
boolean created = dr.mkdirs();
|
||||||
if (created) {
|
if (created) {
|
||||||
@ -440,7 +457,12 @@ public class RulesTest {
|
|||||||
private RedactionLog loadSavedRedactionLog(String pdfFileName) {
|
private RedactionLog loadSavedRedactionLog(String pdfFileName) {
|
||||||
|
|
||||||
File pdfFile = new File(pdfFileName);
|
File pdfFile = new File(pdfFileName);
|
||||||
String directory = REDACTION_LOG_PATH + pdfFile.getParentFile().getPath();
|
String directory = pdfFile.getParentFile().getPath();
|
||||||
|
if (StringUtils.contains(directory, RESOURCES_PATH) || StringUtils.contains(directory, StringUtils.replace(RESOURCES_PATH, "/", "\\"))) {
|
||||||
|
directory = directory + "\\" + REDACTION_LOG_PATH;
|
||||||
|
} else {
|
||||||
|
directory = REDACTION_LOG_RESOURCES_PATH + directory;
|
||||||
|
}
|
||||||
String fileName = StringUtils.replace(pdfFile.getName(), ".pdf", ".json");
|
String fileName = StringUtils.replace(pdfFile.getName(), ".pdf", ".json");
|
||||||
File file = new File(directory, fileName);
|
File file = new File(directory, fileName);
|
||||||
assertThat(file).exists();
|
assertThat(file).exists();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user