RED-4510: Generated Redaction Log and Generating will not run with profile
This commit is contained in:
parent
79aee79567
commit
a4f2b2a1d8
@ -49,6 +49,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.test.annotation.IfProfileValue;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
@ -176,7 +177,9 @@ public class RulesTest {
|
|||||||
.hexColor("#ffe187")
|
.hexColor("#ffe187")
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
|
||||||
.isCaseInsensitive(caseInSensitiveMap.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(null);
|
||||||
mockDictionaryCalls(0L);
|
mockDictionaryCalls(0L);
|
||||||
@ -214,7 +217,6 @@ public class RulesTest {
|
|||||||
* Please commit generated files, if not the following tests will fail
|
* Please commit generated files, if not the following tests will fail
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
// @Ignore// TODO PSC REMOVE
|
|
||||||
public void generateRedactionLogForAllFiles() {
|
public void generateRedactionLogForAllFiles() {
|
||||||
|
|
||||||
Set<String> files = getFileNames(new HashSet<>(), FileSystems.getDefault().getPath(RESOURCES_PATH));
|
Set<String> files = getFileNames(new HashSet<>(), FileSystems.getDefault().getPath(RESOURCES_PATH));
|
||||||
@ -223,9 +225,6 @@ 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.
|
||||||
@ -242,31 +241,22 @@ public class RulesTest {
|
|||||||
* Analyses all files and compares its RedactionLog with saved one from here: REDACTION_LOG_PATH.
|
* Analyses all files and compares its RedactionLog with saved one from here: REDACTION_LOG_PATH.
|
||||||
* If RedactionLog Json for one file does not exist, whole test will fail.
|
* If RedactionLog Json for one file does not exist, whole test will fail.
|
||||||
*/
|
*/
|
||||||
// @IfProfileValue(name = "test-groups", value = "rules-test") //TODO PSC
|
@IfProfileValue(name = "test-groups", value = "rules-test") //TODO PSC
|
||||||
@Test
|
@Test
|
||||||
public void analyseAllFilesAndCompareRedactionLogs() {
|
public void analyseAllFilesAndCompareRedactionLogs() {
|
||||||
|
|
||||||
Set<String> files = getFileNames(new HashSet<>(), FileSystems.getDefault().getPath(RESOURCES_PATH));
|
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("Will analyse " + files.size() + " files and compare its RedactionLogs.");
|
||||||
|
|
||||||
System.out.println("files: " + files);
|
|
||||||
|
|
||||||
files.forEach(this::analyseFileAndCompareRedactionLog);
|
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) {
|
private void generateAndSaveRedactionLog(String fileName) {
|
||||||
|
|
||||||
generateAndSaveRedactionLog(fileName, false);
|
generateAndSaveRedactionLog(fileName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private void generateAndSaveRedactionLog(String fileName, boolean force) {
|
private void generateAndSaveRedactionLog(String fileName, boolean force) {
|
||||||
|
|
||||||
@ -368,7 +358,7 @@ public class RulesTest {
|
|||||||
.filter(r -> r.getHeight() == rectangle.getHeight())
|
.filter(r -> r.getHeight() == rectangle.getHeight())
|
||||||
.filter(r -> r.getWidth() == rectangle.getWidth())
|
.filter(r -> r.getWidth() == rectangle.getWidth())
|
||||||
.findFirst();
|
.findFirst();
|
||||||
// assertThat(savedRectangle).isPresent(); TODO PSC
|
// assertThat(savedRectangle).isPresent(); TODO PSC !!!
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RedactionLogComment comment : redactionLogEntry.getComments()) {
|
for (RedactionLogComment comment : redactionLogEntry.getComments()) {
|
||||||
@ -412,9 +402,6 @@ public class RulesTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cleanPath(String path) {
|
|
||||||
return StringUtils.replace(path, "\\", "/");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean doesRedactionLogExist(String pdfFileName) {
|
private boolean doesRedactionLogExist(String pdfFileName) {
|
||||||
|
|
||||||
@ -460,11 +447,9 @@ public class RulesTest {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private RedactionLog loadSavedRedactionLog(String pdfFileName) {
|
private RedactionLog loadSavedRedactionLog(String pdfFileName) {
|
||||||
|
|
||||||
System.out.println("XXXXXXXXX pdfFileName: " + pdfFileName);
|
|
||||||
|
|
||||||
File pdfFile = new File(pdfFileName);
|
File pdfFile = new File(pdfFileName);
|
||||||
String directory = cleanPath(pdfFile.getParentFile().getPath());
|
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, "/")) {
|
if (!StringUtils.endsWith(directory, "/")) {
|
||||||
directory = directory + "/";
|
directory = directory + "/";
|
||||||
}
|
}
|
||||||
@ -476,17 +461,20 @@ public class RulesTest {
|
|||||||
directory = REDACTION_LOG_RESOURCES_PATH + directory;
|
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);
|
||||||
|
|
||||||
System.out.println("XXXXXXXXX directory: " + directory);
|
|
||||||
System.out.println("XXXXXXXXX fileName: " + fileName);
|
|
||||||
|
|
||||||
assertThat(file).exists();
|
assertThat(file).exists();
|
||||||
|
|
||||||
return objectMapper.readValue(file, RedactionLog.class);
|
return objectMapper.readValue(file, RedactionLog.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String cleanPath(String path) {
|
||||||
|
|
||||||
|
return StringUtils.replace(path, "\\", "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private void loadNerForTest() {
|
private void loadNerForTest() {
|
||||||
|
|
||||||
@ -634,17 +622,8 @@ public class RulesTest {
|
|||||||
getFileNames(fileNames, path);
|
getFileNames(fileNames, path);
|
||||||
} else if (StringUtils.endsWith(path.toAbsolutePath().toString(), ".pdf")) {
|
} else if (StringUtils.endsWith(path.toAbsolutePath().toString(), ".pdf")) {
|
||||||
String absolutePath = cleanPath(path.toAbsolutePath().toString());
|
String absolutePath = cleanPath(path.toAbsolutePath().toString());
|
||||||
System.out.println("absolutePath: " + absolutePath);
|
|
||||||
|
|
||||||
int pos = StringUtils.indexOf(absolutePath, RESOURCES_PATH) + RESOURCES_PATH.length();
|
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));
|
fileNames.add(StringUtils.substring(absolutePath, pos));
|
||||||
System.out.println("Added: " + StringUtils.substring(absolutePath, pos));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user