Compare commits

...

1 Commits

Author SHA1 Message Date
Corina Olariu
5df01893b2 RED-9132 - Remove debug information from Paragraph/Location field
- check the section value for regex expression to identify and remove the leading numbering
- added junit test
- update springboot version, fagiani paket and openfeign version
2024-05-13 12:04:33 +03:00
3 changed files with 51 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
plugins {
application
id("com.iqser.red.service.java-conventions")
id("org.springframework.boot") version "3.1.5"
id("org.springframework.boot") version "3.2.3"
id("io.spring.dependency-management") version "1.1.0"
id("org.sonarqube") version "4.2.1.3168"
id("io.freefair.lombok") version "8.4"
@ -17,7 +17,7 @@ val storageCommonsVersion = "2.45.0"
val poiVersion = "5.2.3"
val metricCommonsVersion = "2.1.0"
val persistenceServiceVersion = "2.380.0"
val springBootStarterVersion = "3.1.5"
val springBootStarterVersion = "3.2.3"
configurations {
all {
@ -44,7 +44,7 @@ dependencies {
implementation("org.apache.poi:poi-scratchpad:${poiVersion}")
implementation("org.springframework.boot:spring-boot-starter-amqp:${springBootStarterVersion}")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.4")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.1.1")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("net.logstash.logback:logstash-logback-encoder:7.4")
@ -69,7 +69,7 @@ tasks.named<BootBuildImage>("bootBuildImage") {
buildpacks.set(
listOf(
"ghcr.io/fagiani/buildpacks/fagiani_apt@sha256:6471c8c70f32b749e29f65ae562ac0339fecad26aa9217628c00a6c31f197dae",
"ghcr.io/knsita/buildpacks/fagiani_apt@sha256:9771d4d27d8050aee62769490b8882fffc794745c129fb98e1f33196e2c93504",
"urn:cnb:builder:paketo-buildpacks/java"
)
)

View File

@ -39,6 +39,8 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor
public class EntityLogConverterService {
private final static String numericalIdentifierPatternForSection = "^.*\\d\\s*+\\]\\:";
private final DossierClient dossierClient;
private final DictionaryClient dictionaryClient;
@ -193,7 +195,7 @@ public class EntityLogConverterService {
private String getSection(EntityLogEntry entry, Position position) {
if (StringUtils.isNotBlank(entry.getSection())) {
return entry.getSection();
return removeNumericalIdentifierPatternFromSection(entry.getSection());
}
if (entry.getEntryType() == EntryType.IMAGE || entry.getEntryType() == EntryType.IMAGE_HINT) {
@ -208,6 +210,16 @@ public class EntityLogConverterService {
}
public String removeNumericalIdentifierPatternFromSection(String section) {
String[] sectionParts = section.split(numericalIdentifierPatternForSection);
if (sectionParts.length > 1) {
return sectionParts[1].trim();
}
return section.trim();
}
private String checkTextForNull(String text) {
if (text == null) {

View File

@ -80,10 +80,43 @@ public class EntityLogConverterServiceTest {
assertFalse(reportEntries.isEmpty());
assertEquals(reportEntries.size(), 61);
assertEquals(reportEntries.get(0).getPage(), 1);
assertEquals(reportEntries.get(0).getSection(), "[1]: Section: Rule 1/2: Redact CBI");
assertEquals(reportEntries.get(0).getSection(), "Section: Rule 1/2: Redact CBI");
assertEquals(reportEntries.get(0).getJustification(), "Article 39(e)(3) of Regulation (EC) No 178/2002 ");
assertEquals(reportEntries.get(0).getJustificationParagraph(), "Article 39(e)(3) of Regulation (EC) No 178/2002");
assertFalse(reportEntries.get(0).isSkipped());
}
@Test
public void testSection() {
String sectionResult = "Paragraph";
String section1 = "[1.1.1]: Paragraph";
String section2 = "[1. 1.1]: Paragraph";
String section3 = "[1,1.1]: Paragraph";
String section4 = "[1,1,1]: Paragraph";
String section5 = "[29]: Paragraph";
String section6 = "[29 ]: Paragraph";
String section7 = "[ 1, 1 . 2]: Paragraph";
String section8 = "[ 29]: Paragraph";
String section9 = "[ 1.1.1]: Paragraph";
String section10 = "[ 29 ]: Paragraph";
String section11 = "[ 1, 1. 1]: Paragraph";
String section12 = " Paragraph";
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section1), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section2), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section3), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section4), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section5), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section6), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section7), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section8), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section9), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section10), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section11), sectionResult);
assertEquals(entityLogConverterService.removeNumericalIdentifierPatternFromSection(section12), sectionResult);
}
}