Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOD-837 #25

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

public enum AppErrorCodeMessageEnum implements AppErrorCodeMessageInterface {
DATE_BAD_REQUEST("0400", "bad.request", RestResponse.Status.BAD_REQUEST),
INTERVAL_TOO_LARGE("0400.1", "bad.request.interval.too.large", RestResponse.Status.BAD_REQUEST),
FLOW_NOT_FOUND("0404", "flow.not.found", RestResponse.Status.NOT_FOUND),
FLOW_NOT_FOUND_CLIENT("1404", "flow.not.found", RestResponse.Status.NOT_FOUND),
UNAUTHORIZED_CLIENT("1401", "system.error", RestResponse.Status.INTERNAL_SERVER_ERROR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import it.gov.pagopa.fdrtechsupport.resources.response.FrResponse;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.jboss.logging.Logger;
import org.openapi.quarkus.api_fdr_json.model.FdrByPspIdIuvIurBase;
import org.openapi.quarkus.api_fdr_nodo_json.model.GetXmlRendicontazioneResponse;

import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

@ApplicationScoped
public class WorkerService {

Expand Down Expand Up @@ -241,9 +241,6 @@ private DateRequest verifyDate(LocalDate dateFrom, LocalDate dateTo) {
dateTo = LocalDate.now();
dateFrom = dateTo.minusDays(dateRangeLimit);
}
if (ChronoUnit.DAYS.between(dateFrom, dateTo) > dateRangeLimit) {
throw new AppException(AppErrorCodeMessageEnum.INTERVAL_TOO_LARGE, dateRangeLimit);
}
return DateRequest.builder().from(dateFrom).to(dateTo).build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package it.gov.pagopa.fdrtechsupport.resources;

import static io.restassured.RestAssured.given;
import static it.gov.pagopa.fdrtechsupport.util.AppConstantTestHelper.PSP_CODE;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;

import com.azure.data.tables.TableClient;
import com.azure.data.tables.TableServiceClient;
import com.azure.data.tables.TableServiceClientBuilder;
Expand All @@ -16,14 +10,21 @@
import it.gov.pagopa.fdrtechsupport.models.FdrBaseInfo;
import it.gov.pagopa.fdrtechsupport.resources.response.FrResponse;
import it.gov.pagopa.fdrtechsupport.util.AppConstantTestHelper;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.List;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;

import static io.restassured.RestAssured.given;
import static it.gov.pagopa.fdrtechsupport.util.AppConstantTestHelper.PSP_CODE;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;

@QuarkusTest
@QuarkusTestResource(MockServerTestResource.class)
Expand Down Expand Up @@ -74,6 +75,17 @@ void testGetFdrByPspAndIur() {
equalTo(created.atStartOfDay().atOffset(ZoneOffset.UTC)));
}

@Test
void wideDateRange() {

given()
.param("dateFrom", "2021-07-01")
.param("dateTo", "2022-07-01")
.when()
.get(url.formatted(25, 1))
.then()
.statusCode(equalTo(200));
}
@Test
void testGetFdrByPspAndIurMalformedError() {

Expand Down
Loading