### Question:
AisConsentUsageService { @Transactional public Map<String, Integer> getUsageCounterMap(ConsentEntity consent) { return aisConsentUsageRepository.findReadByConsentAndUsageDate(consent, LocalDate.now()) .stream() .collect(Collectors.toMap(AisConsentUsage::getRequestUri, u -> Math.max(consent.getFrequencyPerDay() - u.getUsage(), 0))); }  @Transactional void incrementUsage(ConsentEntity consent, AisConsentActionRequest request); @Transactional void resetUsage(ConsentEntity consent); @Transactional Map<String, Integer> getUsageCounterMap(ConsentEntity consent);  }### Answer:
@Test void getUsageCounterMap() { int frequencyPerDay = 30; ConsentEntity consentEntity = new ConsentEntity(); consentEntity.setFrequencyPerDay(frequencyPerDay); List<AisConsentUsage> aisConsentUsageList = Arrays.asList(buildAisConsentUsage(5, "uri_1"), buildAisConsentUsage(8, "uri_2"), buildAisConsentUsage(10, "uri_3")); when(aisConsentUsageRepository.findReadByConsentAndUsageDate(eq(consentEntity), any(LocalDate.class))).thenReturn(aisConsentUsageList); Map<String, Integer> usageCounterMap = aisConsentUsageService.getUsageCounterMap(consentEntity); aisConsentUsageList.forEach(aisConsentUsage -> assertEquals(frequencyPerDay - aisConsentUsage.getUsage(), usageCounterMap.get(aisConsentUsage.getRequestUri()))); }