fixed prometheus test
This commit is contained in:
parent
83f9ce36ce
commit
f41a5c8985
|
@ -2,6 +2,7 @@ package metrics;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.controllers.PrometheusController;
|
import eu.dnetlib.repo.manager.controllers.PrometheusController;
|
||||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||||
|
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
|
@ -23,6 +24,10 @@ public class PrometheusTest {
|
||||||
@Mock
|
@Mock
|
||||||
PiWikService piWikService;
|
PiWikService piWikService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Mock
|
||||||
|
RepositoryService repositoryService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
private PrometheusController prometheusController;
|
private PrometheusController prometheusController;
|
||||||
|
@ -34,6 +39,7 @@ public class PrometheusTest {
|
||||||
when(piWikService.getTotal()).thenReturn(TOTAL);
|
when(piWikService.getTotal()).thenReturn(TOTAL);
|
||||||
when(piWikService.getValidated(true)).thenReturn(VALIDATED);
|
when(piWikService.getValidated(true)).thenReturn(VALIDATED);
|
||||||
when(piWikService.getValidated(false)).thenReturn(TOTAL - VALIDATED);
|
when(piWikService.getValidated(false)).thenReturn(TOTAL - VALIDATED);
|
||||||
|
when(repositoryService.getTotalRegisteredRepositories()).thenReturn(TOTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,8 +53,9 @@ public class PrometheusTest {
|
||||||
public void testPiwikMetrics() {
|
public void testPiwikMetrics() {
|
||||||
assertTrue(piWikService.getValidated(false).equals(TOTAL - VALIDATED));
|
assertTrue(piWikService.getValidated(false).equals(TOTAL - VALIDATED));
|
||||||
String report = prometheusController.getPiwikMetrics();
|
String report = prometheusController.getPiwikMetrics();
|
||||||
assertTrue(report.contains("total_total " + TOTAL));
|
assertTrue(report.contains("provide_repositories_registered_total " + TOTAL));
|
||||||
assertTrue(report.contains("validated_total " + VALIDATED));
|
assertTrue(report.contains("provide_usagecounts_repositories_registered_total " + TOTAL));
|
||||||
|
assertTrue(report.contains("provide_usagecounts_repositories_validated_total " + VALIDATED));
|
||||||
System.out.println(report);
|
System.out.println(report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue