Skip to content

Commit

Permalink
fix: set insensitive case on payfit website
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien authored and fabiengo committed Nov 12, 2024
1 parent a5c5caf commit 0f314b7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import java.util.stream.Collectors;

import static fr.dossierfacile.common.entity.BarCodeType.TWO_D_DOC;
import static fr.dossierfacile.common.enums.FileAuthenticationStatus.API_ERROR;
import static fr.dossierfacile.common.enums.FileAuthenticationStatus.INVALID;
import static fr.dossierfacile.common.enums.FileAuthenticationStatus.VALID;
import static fr.dossierfacile.common.enums.FileAuthenticationStatus.*;

@AllArgsConstructor
public class DisplayableBarCodeFileAnalysis {
Expand Down Expand Up @@ -131,14 +129,15 @@ static String format(Object object) {
@Override
public String toString() {
Map<String, String> map = new HashMap<>();
map.put("Entreprise", companyName);
map.put("Employé", employeeName);
map.put("Salaire net", netSalary);
if (period != null && period.getStart() != null && period.getEnd() != null) {
map.put("Période", dateFormatter.format(period.getStart()) + " - " + dateFormatter.format(period.getEnd()));
} else {
map.put("Période", "Péride absente");
}
map.put("Entreprise", String.valueOf(companyName));
map.put("Employé", String.valueOf(employeeName));
map.put("Salaire net", String.valueOf(netSalary));

map.put("Période", Optional.ofNullable(period)
.filter(p -> p.getStart() != null && p.getEnd() != null)
.map(p -> dateFormatter.format(p.getStart()) + " - " + dateFormatter.format(p.getEnd()))
.orElse(""));

return formatToList(map);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Builder
@Getter
public class PaySlipVerifiedContent {
private static final Pattern PERIOD_PATTERN = Pattern.compile("Période du (\\d{2}/\\d{2}/\\d{4}) au (\\d{2}/\\d{2}/\\d{4})");
private static final Pattern PERIOD_PATTERN = Pattern.compile("P[ée]riode du (\\d{2}/\\d{2}/\\d{4}) au (\\d{2}/\\d{2}/\\d{4})", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy");

private final String companyName;
Expand Down Expand Up @@ -48,7 +48,7 @@ private static DateRange extractPeriod(String header) {

private static String extractFrom(List<PayfitResponse.Info> list, String label) {
return list.stream()
.filter(info -> label.equals(info.getLabel()))
.filter(info -> label.equalsIgnoreCase(info.getLabel()))
.findFirst()
.map(PayfitResponse.Info::getValue)
.orElse("");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.dossierfacile.process.file.service.qrcodeanalysis.payfit;

import fr.dossierfacile.common.repository.ApplicationLogRepository;
import fr.dossierfacile.process.file.IntegrationTest;
import fr.dossierfacile.process.file.TestFilesUtil;
import fr.dossierfacile.process.file.service.qrcodeanalysis.AuthenticationResult;
Expand All @@ -8,6 +9,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -17,6 +19,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.LocalDate;
import java.util.Optional;

import static fr.dossierfacile.common.entity.BarCodeDocumentType.PAYFIT_PAYSLIP;
Expand All @@ -32,6 +35,8 @@
@Disabled
@IntegrationTest
class PayfitDocumentIssuerTest {
@MockBean
ApplicationLogRepository applicationLogRepository;

@Autowired
private PayfitDocumentIssuer payfit;
Expand All @@ -58,7 +63,8 @@ void should_authenticate_payfit_document() throws IOException, URISyntaxExceptio
.hasValueSatisfying(result -> assertAll(
() -> assertThat(result.getDocumentType()).isEqualTo(PAYFIT_PAYSLIP),
() -> assertThat(result.getAuthenticationStatus()).isEqualTo(VALID),
() -> assertThat(result.getApiResponse()).isInstanceOf(PaySlipVerifiedContent.class)
() -> assertThat(result.getApiResponse()).isInstanceOf(PaySlipVerifiedContent.class),
() -> assertThat(result.getApiResponse().getPeriod().getStart()).isEqualTo(LocalDate.of(2023,3,1))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ server.port=${port:8080}
server.tomcat.uri-encoding=UTF-8
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
application.base.url=
application.api.version=4
application.name=process

#Liquibase Configuration
spring.liquibase.enabled=false
Expand All @@ -13,7 +15,10 @@ spring.liquibase.change-log=classpath:db/changelog/databaseChangeLog.xml
rabbitmq.prefetch=3
rabbitmq.document.analyze.delay=20000
analysis.timeout.seconds=1

document.analysis.delay.ms=500
document.analysis.timeout.ms=5000
file.analysis.timeout.ms=5000
file.minify.timeout.ms=5000

#Database Server Configuration
spring.datasource.driver-class-name=org.h2.Driver
Expand Down

0 comments on commit 0f314b7

Please sign in to comment.