Search in sources :

Example 16 with RepositoryStatistics

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

Example 17 with RepositoryStatistics

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();
}
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 18 with RepositoryStatistics

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

Aggregations

RepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics)18 DefaultRepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)14 Test (org.junit.Test)11 Date (java.util.Date)9 ArrayList (java.util.ArrayList)7 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)4 Path (java.nio.file.Path)3 ArtifactReference (org.apache.archiva.model.ArtifactReference)3 RepositoryTask (org.apache.archiva.scheduler.repository.model.RepositoryTask)3 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Locale (java.util.Locale)1 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 TaskExecutionException (org.apache.archiva.redback.components.taskqueue.execution.TaskExecutionException)1 ManagedRepository (org.apache.archiva.repository.ManagedRepository)1 RepositoryScanStatistics (org.apache.archiva.repository.scanner.RepositoryScanStatistics)1 RepositoryScannerException (org.apache.archiva.repository.scanner.RepositoryScannerException)1 ArchivaRepositoryStatistics (org.apache.archiva.rest.api.model.ArchivaRepositoryStatistics)1