use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetStatsRangeNotInside.
@Test
public void testGetStatsRangeNotInside() throws Exception {
walkRepository(3);
Date current = new Date();
addStats(new Date(current.getTime() - 12345), new Date(current.getTime() - 6000));
addStats(new Date(current.getTime() - 3000), new Date(current.getTime() - 2000));
addStats(new Date(current.getTime() - 1000), current);
ArrayList<String> keys = new ArrayList<>(statsCreated.keySet());
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(keys);
metadataRepositoryControl.replay();
for (RepositoryStatistics stats : statsCreated.values()) {
repositoryStatisticsManager.addStatisticsAfterScan(metadataRepository, TEST_REPO_ID, stats.getScanStartTime(), stats.getScanEndTime(), 56345, 45);
}
List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange(metadataRepository, TEST_REPO_ID, new Date(current.getTime() - 20000), new Date(current.getTime() - 16000));
assertEquals(0, list.size());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetLatestStats.
@Test
public void testGetLatestStats() throws Exception {
Date startTime = TIMESTAMP_FORMAT.parse(SECOND_TEST_SCAN);
Date endTime = new Date(startTime.getTime() + 60000);
DefaultRepositoryStatistics defStats = new DefaultRepositoryStatistics();
defStats.setScanStartTime(startTime);
defStats.setScanEndTime(endTime);
RepositoryStatistics stats = defStats;
stats.setTotalArtifactFileSize(1314527915L);
stats.setNewFileCount(123);
stats.setTotalArtifactCount(10386);
stats.setTotalProjectCount(2031);
stats.setTotalGroupCount(529);
stats.setTotalFileCount(56229);
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(Arrays.asList(FIRST_TEST_SCAN, SECOND_TEST_SCAN));
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, SECOND_TEST_SCAN)).andReturn(stats);
metadataRepositoryControl.replay();
stats = repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID);
assertNotNull(stats);
assertEquals(1314527915L, stats.getTotalArtifactFileSize());
assertEquals(123, stats.getNewFileCount());
assertEquals(10386, stats.getTotalArtifactCount());
assertEquals(2031, stats.getTotalProjectCount());
assertEquals(529, stats.getTotalGroupCount());
assertEquals(56229, stats.getTotalFileCount());
assertEquals(SECOND_TEST_SCAN, TIMESTAMP_FORMAT.format(stats.getScanStartTime()));
assertEquals(SECOND_TEST_SCAN, stats.getName());
assertEquals(endTime, stats.getScanEndTime());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetLatestStatsWhenEmpty.
@Test
public void testGetLatestStatsWhenEmpty() throws Exception {
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(Collections.<String>emptyList());
metadataRepositoryControl.replay();
RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID);
assertNull(stats);
metadataRepositoryControl.verify();
}
Aggregations