Skip to content

Commit

Permalink
[PAGOPA-2359] sonar coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aacitelli authored and aacitelli committed Nov 27, 2024
2 parents 77cd8e2 + 80b0076 commit 858f15c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class PaymentPositionRepository implements PanacheRepository<PaymentPosition> {

@ConfigProperty(name = "app.payment_pull.keep_aca", defaultValue = "true")
private boolean keepAca;
public boolean keepAca;

// the pull flag has no business value -> for future needs
private static final String BASE_QUERY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import it.gov.pagopa.gpd.payments.pull.models.enums.DebtPositionStatus;
import it.gov.pagopa.gpd.payments.pull.models.enums.ServiceType;
import it.gov.pagopa.gpd.payments.pull.models.enums.Type;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -26,9 +27,12 @@ class PaymentPositionRepositoryTest {

@InjectSpy
PaymentPositionRepository paymentPositionRepository;


@Test
void findNoticesOnRepositoryWithoutDueDate() {
// force keepAca to true
paymentPositionRepository.keepAca = true;
PanacheQuery panacheQuery = Mockito.mock(PanacheQuery.class);
when(paymentPositionRepository.find(paymentPositionRepository.buildQueryBase(), FISCAL_CODE)).thenReturn(panacheQuery);
when(panacheQuery.page(any())).thenReturn(panacheQuery);
Expand All @@ -50,6 +54,8 @@ void findNoticesOnRepositoryWithoutDueDate() {

@Test
void findNoticesOnRepositoryWithDueDate() {
// force keepAca to true
paymentPositionRepository.keepAca = true;
PanacheQuery panacheQuery = Mockito.mock(PanacheQuery.class);
when(paymentPositionRepository.find(paymentPositionRepository.buildQueryWithDueDate(), FISCAL_CODE, DUE_DATE.atStartOfDay()))
.thenReturn(panacheQuery);
Expand All @@ -72,7 +78,7 @@ void findNoticesOnRepositoryWithDueDate() {
@Test
void findNoticesOnRepositoryForKeepACAFalse() {
// force keepAca to false
System.setProperty("app.payment_pull.keep_aca", "false");
paymentPositionRepository.keepAca = false;
PanacheQuery panacheQuery = Mockito.mock(PanacheQuery.class);
when(paymentPositionRepository.find(paymentPositionRepository.buildQueryBase(), FISCAL_CODE)).thenReturn(panacheQuery);
when(panacheQuery.page(any())).thenReturn(panacheQuery);
Expand Down

0 comments on commit 858f15c

Please sign in to comment.