diff --git a/src/test/java/it/gov/pagopa/onboarding/citizen/repository/CitizenSpecificRepositoryImplTest.java b/src/test/java/it/gov/pagopa/onboarding/citizen/repository/CitizenSpecificRepositoryImplTest.java index 4e555ec..9688b58 100644 --- a/src/test/java/it/gov/pagopa/onboarding/citizen/repository/CitizenSpecificRepositoryImplTest.java +++ b/src/test/java/it/gov/pagopa/onboarding/citizen/repository/CitizenSpecificRepositoryImplTest.java @@ -128,4 +128,21 @@ private CitizenConsent createMockCitizenConsent(String hashedFiscalCode, String return citizenConsent; } + + @Test + void testFindByTppIdEnabled_Success() { + String tppId = "tpp1"; + CitizenConsent citizenConsent = createMockCitizenConsent("hashedCode", tppId); + + when(mongoTemplate.aggregate( + Mockito.any(Aggregation.class), + Mockito.eq("citizen_consents"), + Mockito.eq(CitizenConsent.class) + )).thenReturn(Flux.just(citizenConsent)); + + StepVerifier.create(repository.findByTppIdEnabled(tppId)) + .expectNextMatches(result -> result.getConsents().containsKey(tppId) && result.getConsents().get(tppId).getTppState()) + .verifyComplete(); + + } }