Package org.apache.archiva.metadata.repository.stats

Examples of org.apache.archiva.metadata.repository.stats.RepositoryStatistics$ZeroForNullHashMap


        assertNotNull( unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0,
                      unprocessedResultList.size() );

        // check correctness of new stats
        RepositoryStatistics newStats =
            repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
        assertEquals( 0, newStats.getNewFileCount() );
        assertEquals( 31, newStats.getTotalFileCount() );
        // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
//        assertEquals( 8, newStats.getTotalArtifactCount() );
//        assertEquals( 3, newStats.getTotalGroupCount() );
//        assertEquals( 5, newStats.getTotalProjectCount() );
//        assertEquals( 14159, newStats.getTotalArtifactFileSize() );

        File newArtifactGroup = new File( repoDir, "org/apache/archiva" );

        FileUtils.copyDirectoryStructure( new File( "target/test-classes/test-repo/org/apache/archiva" ),
                                          newArtifactGroup );

        // update last modified date
        new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/pom.xml" ).setLastModified(
            Calendar.getInstance().getTimeInMillis() + 1000 );
        new File( newArtifactGroup,
                  "archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ).setLastModified(
            Calendar.getInstance().getTimeInMillis() + 1000 );

        assertTrue( newArtifactGroup.exists() );

        taskExecutor.executeTask( repoTask );

        unprocessedResultList = testConsumer.getConsumed();
        assertNotNull( unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
                      unprocessedResultList.size() );

        // check correctness of new stats
        RepositoryStatistics updatedStats =
            repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
        assertEquals( 2, updatedStats.getNewFileCount() );
        assertEquals( 33, updatedStats.getTotalFileCount() );
        // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
//        assertEquals( 8, newStats.getTotalArtifactCount() );
//        assertEquals( 3, newStats.getTotalGroupCount() );
//        assertEquals( 5, newStats.getTotalProjectCount() );
//        assertEquals( 19301, updatedStats.getTotalArtifactFileSize() );
View Full Code Here


        assertNotNull( unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
                      unprocessedResultList.size() );

        // check correctness of new stats
        RepositoryStatistics newStats =
            repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
        assertEquals( 2, newStats.getNewFileCount() );
        assertEquals( 33, newStats.getTotalFileCount() );
        // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
//        assertEquals( 8, newStats.getTotalArtifactCount() );
//        assertEquals( 3, newStats.getTotalGroupCount() );
//        assertEquals( 5, newStats.getTotalProjectCount() );
//        assertEquals( 19301, newStats.getTotalArtifactFileSize() );
View Full Code Here

        assertNotNull( unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
                      unprocessedResultList.size() );

        // check correctness of new stats
        RepositoryStatistics newStats =
            repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
        assertEquals( 2, newStats.getNewFileCount() );
        assertEquals( 33, newStats.getTotalFileCount() );
        // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
//        assertEquals( 8, newStats.getTotalArtifactCount() );
//        assertEquals( 3, newStats.getTotalGroupCount() );
//        assertEquals( 5, newStats.getTotalProjectCount() );
//        assertEquals( 19301, newStats.getTotalArtifactFileSize() );
View Full Code Here

    private void createAndSaveTestStats()
        throws MetadataRepositoryException
    {
        Date date = Calendar.getInstance().getTime();
        RepositoryStatistics stats = new RepositoryStatistics();
        stats.setScanStartTime( new Date( date.getTime() - 1234567 ) );
        stats.setScanEndTime( date );
        stats.setNewFileCount( 31 );
        stats.setTotalArtifactCount( 8 );
        stats.setTotalFileCount( 31 );
        stats.setTotalGroupCount( 3 );
        stats.setTotalProjectCount( 5 );
        stats.setTotalArtifactFileSize( 38545 );

        repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
                                                            new Date( date.getTime() - 1234567 ), date, 31, 31 );
    }
View Full Code Here

                        // TODO set repo's stats to 0
                        continue;
                    }

                    // only the first one
                    RepositoryStatistics repositoryStats = stats.get( 0 );
                    repositoryStatistics.add( repositoryStats );

                    input.append( repo ).append( "," );
                    input.append( repositoryStats.getTotalFileCount() ).append( "," );
                    input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
                    input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
                    input.append( repositoryStats.getTotalGroupCount() ).append( "," );
                    input.append( repositoryStats.getTotalProjectCount() ).append( "," );
                    input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
                    input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
                    input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
                    input.append( repositoryStats.getTotalCountForType( "war" ) );
                    input.append( "\n" );
                }
            }
            else if ( selectedRepositories.size() == 1 )
            {
                repositoryId = selectedRepositories.get( 0 );
                try
                {
                    startDateInDF = getStartDateInDateFormat();
                    endDateInDF = getEndDateInDateFormat();

                    if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
                    {
                        addFieldError( "startDate", "Start Date must be earlier than the End Date" );
                        return INPUT;
                    }

                    List<RepositoryStatistics> stats = null;
                    try
                    {
                        stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repositoryId,
                                                                                  startDateInDF, endDateInDF );
                    }
                    catch ( MetadataRepositoryException e )
                    {
                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
                    }
                    if ( stats == null || stats.isEmpty() )
                    {
                        addActionError(
                            "No statistics available for repository. Repository might not have been scanned." );
                        return ERROR;
                    }

                    input = new StringBuilder(
                        "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,"
                            + "Archetypes,Jars,Wars\n" );

                    for ( RepositoryStatistics repositoryStats : stats )
                    {
                        input.append( repositoryStats.getScanStartTime() ).append( "," );
                        input.append( repositoryStats.getTotalFileCount() ).append( "," );
                        input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
                        input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
                        input.append( repositoryStats.getTotalGroupCount() ).append( "," );
                        input.append( repositoryStats.getTotalProjectCount() ).append( "," );
                        input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
                        input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
                        input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
                        input.append( repositoryStats.getTotalCountForType( "war" ) );
                        input.append( "\n" );
                    }

                    repositoryStatistics = stats;
                }
View Full Code Here

    public void addStatisticsAfterScan( MetadataRepository metadataRepository, String repositoryId, Date startTime,
                                        Date endTime, long totalFiles, long newFiles )
    {
        List<RepositoryStatistics> stats = getStatsList( repositoryId );

        RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
        repositoryStatistics.setScanStartTime( startTime );
        repositoryStatistics.setScanEndTime( endTime );
        repositoryStatistics.setNewFileCount( newFiles );
        repositoryStatistics.setTotalFileCount( totalFiles );

        stats.add( repositoryStatistics );
    }
View Full Code Here

        return createStats( new Date() );
    }

    private RepositoryStatistics createStats( Date date )
    {
        RepositoryStatistics stats = new RepositoryStatistics();
        stats.setScanStartTime( date );
        return stats;
    }
View Full Code Here

            MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
            control.expectAndReturn( metadataRepository.getMetadataFacets( "internal", RepositoryStatistics.FACET_ID ),
                                     Arrays.asList( "20091125.123456.678" ) );
            control.expectAndReturn(
                metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID, "20091125.123456.678" ),
                new RepositoryStatistics() );
            control.expectAndReturn( metadataRepository.getMetadataFacets( "snapshots", RepositoryStatistics.FACET_ID ),
                                     Arrays.asList( "20091112.012345.012" ) );
            control.expectAndReturn( metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID,
                                                                          "20091112.012345.012" ),
                                     new RepositoryStatistics() );
            control.replay();

            RepositorySession session = mock( RepositorySession.class );
            when( session.getRepository() ).thenReturn( metadataRepository );
            TestRepositorySessionFactory factory =
View Full Code Here

                MetadataRepository metadataRepository = repositorySession.getRepository();
                try
                {
                    if ( !repoTask.isScanAll() )
                    {
                        RepositoryStatistics previousStats =
                            repositoryStatisticsManager.getLastStatistics( metadataRepository, repoId );
                        if ( previousStats != null )
                        {
                            sinceWhen = previousStats.getScanStartTime().getTime();
                            previousFileCount = previousStats.getTotalFileCount();
                        }
                    }

                    RepositoryScanStatistics stats;
                    try
View Full Code Here

        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            for ( ManagedRepository repo : managedRepositories )
            {
                RepositoryStatistics stats = null;
                try
                {
                    stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, repo.getId() );
                }
                catch ( MetadataRepositoryException e )
View Full Code Here

TOP

Related Classes of org.apache.archiva.metadata.repository.stats.RepositoryStatistics$ZeroForNullHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.