Search in sources :

Example 6 with DefaultRepositoryStatistics

use of org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics 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();
}
Also used : RepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics) Date(java.util.Date) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics) Test(org.junit.Test)

Example 7 with DefaultRepositoryStatistics

use of org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics in project archiva by apache.

the class RepositoryStatisticsManagerTest method createTestStats.

private DefaultRepositoryStatistics createTestStats(Date startTime, Date endTime) {
    DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics();
    stats.setRepositoryId(TEST_REPO_ID);
    stats.setScanStartTime(startTime);
    stats.setScanEndTime(endTime);
    stats.setTotalArtifactFileSize(20 * 12345L);
    stats.setNewFileCount(45);
    stats.setTotalArtifactCount(20);
    stats.setTotalProjectCount(5);
    stats.setTotalGroupCount(4);
    stats.setTotalFileCount(56345);
    stats.setTotalCountForType("jar", 10);
    stats.setTotalCountForType("pom", 10);
    return stats;
}
Also used : DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)

Example 8 with DefaultRepositoryStatistics

use of org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics in project archiva by apache.

the class RepositoryStatisticsManagerTest method testDeleteStats.

@Test
public void testDeleteStats() throws Exception {
    walkRepository(2);
    Date current = new Date();
    Date startTime1 = new Date(current.getTime() - 12345);
    DefaultRepositoryStatistics stats1 = createTestStats(startTime1, new Date(current.getTime() - 6000));
    metadataRepository.addMetadataFacet(TEST_REPO_ID, stats1);
    Date startTime2 = new Date(current.getTime() - 3000);
    DefaultRepositoryStatistics stats2 = createTestStats(startTime2, current);
    metadataRepository.addMetadataFacet(TEST_REPO_ID, stats2);
    expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(Arrays.asList(stats1.getName(), stats2.getName()));
    expect(metadataRepository.getMetadataFacet(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, stats2.getName())).andReturn(stats2);
    metadataRepository.removeMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID);
    expect(metadataRepository.getMetadataFacets(TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(Collections.<String>emptyList());
    metadataRepositoryControl.replay();
    repositoryStatisticsManager.addStatisticsAfterScan(metadataRepository, TEST_REPO_ID, startTime1, stats1.getScanEndTime(), 56345, 45);
    repositoryStatisticsManager.addStatisticsAfterScan(metadataRepository, TEST_REPO_ID, startTime2, stats2.getScanEndTime(), 56345, 45);
    assertNotNull(repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID));
    repositoryStatisticsManager.deleteStatistics(metadataRepository, TEST_REPO_ID);
    assertNull(repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID));
    metadataRepositoryControl.verify();
}
Also used : Date(java.util.Date) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics) Test(org.junit.Test)

Aggregations

DefaultRepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)8 Date (java.util.Date)4 Test (org.junit.Test)3 RepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics)2 Calendar (java.util.Calendar)1 AbstractMetadataRepositoryTest (org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest)1 RepositoryStatisticsProvider (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider)1