Compare commits

...
5 changed files with 18 additions and 43 deletions
@@ -177,7 +177,9 @@ public class RulesTest {
.hexColor("#ffe187")
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS))
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS)).rank(rankTypeMap.get(DOSSIER_REDACTIONS)).build()));
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS))
.rank(rankTypeMap.get(DOSSIER_REDACTIONS))
.build()));
mockDictionaryCalls(null);
mockDictionaryCalls(0L);
@@ -215,7 +217,6 @@ public class RulesTest {
* Please commit generated files, if not the following tests will fail
*/
@Test
@Ignore// TODO PSC REMOVE
public void generateRedactionLogForAllFiles() {
Set<String> files = getFileNames(new HashSet<>(), FileSystems.getDefault().getPath(RESOURCES_PATH));
@@ -224,19 +225,16 @@ public class RulesTest {
}
/**
* Analyses file and compares its RedactionLog with saved one from here: REDACTION_LOG_PATH.
* If RedactionLog Json does not exist, test will fail.
* Test is ignored, because it's for manual tests.
*/
@Ignore
@Test
public void analyseFileAndCompareRedactionLog() {
String fileName = "files/Compounds/31 A14111B - EU AIR3 - MCP Section 1 - Identity of the plant protection product.pdf";
String fileName = "files/RulesTest/SYNGENTA_EFSA_sanitisation_GFL_v1_withHighlights.pdf"; //TODO PSC
// String fileName = "scanned/VV-377031.pdf";
// fileName = "files/new/A20622A izRMS (CZ) fRR Part B9.pdf";
analyseFileAndCompareRedactionLog(fileName);
}
@@ -251,25 +249,16 @@ public class RulesTest {
Set<String> files = getFileNames(new HashSet<>(), FileSystems.getDefault().getPath(RESOURCES_PATH));
System.out.println("Will analyse " + files.size() + " files and compare its RedactionLogs.");
System.out.println("files: " + files);
files.forEach(this::analyseFileAndCompareRedactionLog);
}
@Test// TODO PSC REMOVE
@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);
}
private void generateAndSaveRedactionLog(String fileName) {
generateAndSaveRedactionLog(fileName, false);
}
@SneakyThrows
private void generateAndSaveRedactionLog(String fileName, boolean force) {
@@ -371,7 +360,7 @@ public class RulesTest {
.filter(r -> r.getHeight() == rectangle.getHeight())
.filter(r -> r.getWidth() == rectangle.getWidth())
.findFirst();
// assertThat(savedRectangle).isPresent(); TODO PSC
assertThat(savedRectangle).isPresent();
}
for (RedactionLogComment comment : redactionLogEntry.getComments()) {
@@ -415,9 +404,6 @@ public class RulesTest {
}
private String cleanPath(String path) {
return StringUtils.replace(path, "\\", "/");
}
private boolean doesRedactionLogExist(String pdfFileName) {
@@ -463,11 +449,9 @@ public class RulesTest {
@SneakyThrows
private RedactionLog loadSavedRedactionLog(String pdfFileName) {
System.out.println("XXXXXXXXX pdfFileName: " + pdfFileName);
File pdfFile = new File(pdfFileName);
String directory = cleanPath(pdfFile.getParentFile().getPath());
if (StringUtils.contains(directory, RESOURCES_PATH)) {// || StringUtils.contains(directory, StringUtils.replace(RESOURCES_PATH, "/", "\\"))
if (StringUtils.contains(directory, RESOURCES_PATH)) {
if (!StringUtils.endsWith(directory, "/")) {
directory = directory + "/";
}
@@ -479,17 +463,20 @@ public class RulesTest {
directory = REDACTION_LOG_RESOURCES_PATH + directory;
}
String fileName = StringUtils.replace(pdfFile.getName(), ".pdf", ".json");
File file = new File(directory, fileName);
System.out.println("XXXXXXXXX directory: " + directory);
System.out.println("XXXXXXXXX fileName: " + fileName);
assertThat(file).exists();
return objectMapper.readValue(file, RedactionLog.class);
}
private String cleanPath(String path) {
return StringUtils.replace(path, "\\", "/");
}
@SneakyThrows
private void loadNerForTest() {
@@ -637,17 +624,8 @@ public class RulesTest {
getFileNames(fileNames, path);
} else if (StringUtils.endsWith(path.toAbsolutePath().toString(), ".pdf")) {
String absolutePath = cleanPath(path.toAbsolutePath().toString());
System.out.println("absolutePath: " + absolutePath);
int pos = StringUtils.indexOf(absolutePath, RESOURCES_PATH) + RESOURCES_PATH.length();
// if (pos < 0) {
// pos = StringUtils.indexOf(absolutePath, StringUtils.replace(RESOURCES_PATH, "/", "\\"));
// }
// pos += 18;
System.out.println("pos: " + pos);
fileNames.add(StringUtils.substring(absolutePath, pos));
System.out.println("Added: " + StringUtils.substring(absolutePath, pos));
}
}
}
File diff suppressed because one or more lines are too long