use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetStatsRangeLowerAndUpperOutside.
@Test
public void testGetStatsRangeLowerAndUpperOutside() 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);
String key = keys.get(0);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
key = keys.get(1);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
key = keys.get(2);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
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), current);
assertEquals(3, list.size());
assertEquals(new Date(current.getTime() - 12345), list.get(2).getScanStartTime());
assertEquals(new Date(current.getTime() - 3000), list.get(1).getScanStartTime());
assertEquals(new Date(current.getTime() - 1000), list.get(0).getScanStartTime());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetStatsRangeInside.
@Test
public void testGetStatsRangeInside() 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);
// only match the middle one
String key = keys.get(1);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
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() - 4000), new Date(current.getTime() - 2000));
assertEquals(1, list.size());
assertEquals(new Date(current.getTime() - 3000), list.get(0).getScanStartTime());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testAddNewStats.
@Test
public void testAddNewStats() throws Exception {
Date current = new Date();
Date startTime = new Date(current.getTime() - 12345);
RepositoryStatistics stats = createTestStats(startTime, current);
walkRepository(1);
metadataRepository.addMetadataFacet(TEST_REPO_ID, stats);
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(Arrays.asList(stats.getName()));
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, stats.getName())).andReturn(stats);
metadataRepositoryControl.replay();
repositoryStatisticsManager.addStatisticsAfterScan(metadataRepository, TEST_REPO_ID, startTime, current, 56345, 45);
stats = repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID);
assertNotNull(stats);
assertEquals(246900, stats.getTotalArtifactFileSize());
assertEquals(45, stats.getNewFileCount());
assertEquals(20, stats.getTotalArtifactCount());
assertEquals(5, stats.getTotalProjectCount());
assertEquals(4, stats.getTotalGroupCount());
assertEquals(56345, stats.getTotalFileCount());
assertEquals(current.getTime() - 12345, stats.getScanStartTime().getTime());
assertEquals(current, stats.getScanEndTime());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetStatsRangeLowerOutside.
@Test
public void testGetStatsRangeLowerOutside() 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);
List<String> keys = new ArrayList<>(statsCreated.keySet());
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(keys);
String key = keys.get(0);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
key = keys.get(1);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
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() - 2000));
assertEquals(2, list.size());
assertEquals(new Date(current.getTime() - 12345), list.get(1).getScanStartTime());
assertEquals(new Date(current.getTime() - 3000), list.get(0).getScanStartTime());
metadataRepositoryControl.verify();
}
use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics in project archiva by apache.
the class RepositoryStatisticsManagerTest method testGetStatsRangeUpperOutside.
@Test
public void testGetStatsRangeUpperOutside() 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);
List<String> keys = new ArrayList<>(statsCreated.keySet());
expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(keys);
String key = keys.get(1);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
key = keys.get(2);
expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key)).andReturn(statsCreated.get(key));
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() - 4000), current);
assertEquals(2, list.size());
assertEquals(new Date(current.getTime() - 3000), list.get(1).getScanStartTime());
assertEquals(new Date(current.getTime() - 1000), list.get(0).getScanStartTime());
metadataRepositoryControl.verify();
}
Aggregations