mirror of https://github.com/apache/archiva.git
[MRM-1301] add back summary statistics for per-type counts
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@891113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0960c24cfb
commit
63e3253e79
|
@ -298,8 +298,8 @@ public class GenerateReportAction
|
||||||
}
|
}
|
||||||
|
|
||||||
input = new StringBuffer(
|
input = new StringBuffer(
|
||||||
"Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
"Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes," +
|
||||||
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
"Jars,Wars\n" );
|
||||||
|
|
||||||
// multiple repos
|
// multiple repos
|
||||||
for ( String repo : selectedRepositories )
|
for ( String repo : selectedRepositories )
|
||||||
|
@ -322,14 +322,11 @@ public class GenerateReportAction
|
||||||
input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
|
input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
|
input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalGroupCount() ).append( "," );
|
input.append( repositoryStats.getTotalGroupCount() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalProjectCount() );//.append( "," );
|
input.append( repositoryStats.getTotalProjectCount() ).append( "," );
|
||||||
// TODO
|
input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getPluginCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getArchetypeCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getJarCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "war" ) );
|
||||||
// input.append( repositoryStats.getWarCount() ).append( "," );
|
|
||||||
// input.append( repositoryStats.getDeploymentCount() ).append( "," );
|
|
||||||
// input.append( repositoryStats.getDownloadCount() ).append( "\n" );
|
|
||||||
input.append( "\n" );
|
input.append( "\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,8 +353,8 @@ public class GenerateReportAction
|
||||||
}
|
}
|
||||||
|
|
||||||
input = new StringBuffer(
|
input = new StringBuffer(
|
||||||
"Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
"Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins," +
|
||||||
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
"Archetypes,Jars,Wars\n" );
|
||||||
|
|
||||||
for ( RepositoryStatistics repositoryStats : stats )
|
for ( RepositoryStatistics repositoryStats : stats )
|
||||||
{
|
{
|
||||||
|
@ -366,14 +363,11 @@ public class GenerateReportAction
|
||||||
input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
|
input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
|
input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalGroupCount() ).append( "," );
|
input.append( repositoryStats.getTotalGroupCount() ).append( "," );
|
||||||
input.append( repositoryStats.getTotalProjectCount() );//.append( "," );
|
input.append( repositoryStats.getTotalProjectCount() ).append( "," );
|
||||||
// TODO
|
input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getPluginCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getArchetypeCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
|
||||||
// input.append( repositoryStats.getJarCount() ).append( "," );
|
input.append( repositoryStats.getTotalCountForType( "war" ) );
|
||||||
// input.append( repositoryStats.getWarCount() ).append( "," );
|
|
||||||
// input.append( repositoryStats.getDeploymentCount() ).append( "," );
|
|
||||||
// input.append( repositoryStats.getDownloadCount() );
|
|
||||||
input.append( "\n" );
|
input.append( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,10 @@
|
||||||
<th>Artifact Count</th>
|
<th>Artifact Count</th>
|
||||||
<th>Group Count</th>
|
<th>Group Count</th>
|
||||||
<th>Project Count</th>
|
<th>Project Count</th>
|
||||||
<%-- TODO
|
|
||||||
<th>Plugins</th>
|
<th>Plugins</th>
|
||||||
<th>Archetypes</th>
|
<th>Archetypes</th>
|
||||||
<th>Jars</th>
|
<th>Jars</th>
|
||||||
<th>Wars</th>
|
<th>Wars</th>
|
||||||
<th>Deployments</th>
|
|
||||||
<th>Downloads</th>
|
|
||||||
--%>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<c:forEach var="stats" items="${repositoryStatistics}" varStatus="i">
|
<c:forEach var="stats" items="${repositoryStatistics}" varStatus="i">
|
||||||
|
@ -168,15 +164,11 @@
|
||||||
<td align="right">${stats.totalArtifactCount}</td>
|
<td align="right">${stats.totalArtifactCount}</td>
|
||||||
<td align="right">${stats.totalGroupCount}</td>
|
<td align="right">${stats.totalGroupCount}</td>
|
||||||
<td align="right">${stats.totalProjectCount}</td>
|
<td align="right">${stats.totalProjectCount}</td>
|
||||||
<%-- TODO
|
<td align="right">${stats.totalCountForType['maven-plugin']}</td>
|
||||||
<td align="right">${stats.pluginCount}</td>
|
<td align="right">${stats.totalCountForType['maven-archetype']}</td>
|
||||||
<td align="right">${stats.archetypeCount}</td>
|
<td align="right">${stats.totalCountForType['jar']}</td>
|
||||||
<td align="right">${stats.jarCount}</td>
|
<td align="right">${stats.totalCountForType['war']}</td>
|
||||||
<td align="right">${stats.warCount}</td>
|
</tr>
|
||||||
<td align="right">${stats.deploymentCount}</td>
|
|
||||||
<td align="right">${stats.downloadCount}</td>
|
|
||||||
--%>
|
|
||||||
</tr>
|
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</table>
|
</table>
|
||||||
</c:when>
|
</c:when>
|
||||||
|
@ -191,15 +183,11 @@
|
||||||
<th>Artifact Count</th>
|
<th>Artifact Count</th>
|
||||||
<th>Group Count</th>
|
<th>Group Count</th>
|
||||||
<th>Project Count</th>
|
<th>Project Count</th>
|
||||||
<%-- TODO
|
|
||||||
<th>Plugins</th>
|
<th>Plugins</th>
|
||||||
<th>Archetypes</th>
|
<th>Archetypes</th>
|
||||||
<th>Jars</th>
|
<th>Jars</th>
|
||||||
<th>Wars</th>
|
<th>Wars</th>
|
||||||
<th>Deployments</th>
|
</tr>
|
||||||
<th>Downloads</th>
|
|
||||||
--%>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<c:forEach var="stats" items="${repositoryStatistics}">
|
<c:forEach var="stats" items="${repositoryStatistics}">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -209,14 +197,10 @@
|
||||||
<td align="right">${stats.totalArtifactCount}</td>
|
<td align="right">${stats.totalArtifactCount}</td>
|
||||||
<td align="right">${stats.totalGroupCount}</td>
|
<td align="right">${stats.totalGroupCount}</td>
|
||||||
<td align="right">${stats.totalProjectCount}</td>
|
<td align="right">${stats.totalProjectCount}</td>
|
||||||
<%-- TODO
|
<td align="right">${stats.totalCountForType['maven-plugin']}</td>
|
||||||
<td align="right">${stats.pluginCount}</td>
|
<td align="right">${stats.totalCountForType['maven-archetype']}</td>
|
||||||
<td align="right">${stats.archetypeCount}</td>
|
<td align="right">${stats.totalCountForType['jar']}</td>
|
||||||
<td align="right">${stats.jarCount}</td>
|
<td align="right">${stats.totalCountForType['war']}</td>
|
||||||
<td align="right">${stats.warCount}</td>
|
|
||||||
<td align="right">${stats.deploymentCount}</td>
|
|
||||||
<td align="right">${stats.downloadCount}</td>
|
|
||||||
--%>
|
|
||||||
</tr>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -262,12 +262,9 @@ public class GenerateReportActionTest
|
||||||
assertFalse( action.hasActionErrors() );
|
assertFalse( action.hasActionErrors() );
|
||||||
assertFalse( action.hasFieldErrors() );
|
assertFalse( action.hasFieldErrors() );
|
||||||
|
|
||||||
// assertEquals(
|
|
||||||
// "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" +
|
|
||||||
// date + ",0,0,0,0,0,1,0,1,1,0,0\n", IOUtils.toString( action.getInputStream() ) );
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" +
|
"Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" +
|
||||||
date + ",0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
|
date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
|
||||||
repositoryStatisticsManagerControl.verify();
|
repositoryStatisticsManagerControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,12 +578,10 @@ public class GenerateReportActionTest
|
||||||
private void assertMultiRepoCsvResult()
|
private void assertMultiRepoCsvResult()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// assertEquals(
|
|
||||||
// "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" +
|
|
||||||
// "snapshots,0,0,0,0,0,1,0,1,1,0,0\n" + "internal,0,0,0,0,0,1,0,1,1,0,0\n",
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" +
|
"Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" +
|
||||||
"snapshots,0,0,0,0,0\n" + "internal,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
|
"snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n",
|
||||||
|
IOUtils.toString( action.getInputStream() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId )
|
private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId )
|
||||||
|
|
|
@ -51,5 +51,9 @@
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-repository-layer</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -28,6 +28,10 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||||
import org.apache.archiva.metadata.repository.MetadataRepository;
|
import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||||
|
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
|
import org.apache.maven.archiva.repository.RepositoryException;
|
||||||
|
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -44,6 +48,11 @@ public class DefaultRepositoryStatisticsManager
|
||||||
*/
|
*/
|
||||||
private MetadataRepository metadataRepository;
|
private MetadataRepository metadataRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @plexus.requirement
|
||||||
|
*/
|
||||||
|
private RepositoryContentFactory repositoryContentFactory;
|
||||||
|
|
||||||
public RepositoryStatistics getLastStatistics( String repositoryId )
|
public RepositoryStatistics getLastStatistics( String repositoryId )
|
||||||
{
|
{
|
||||||
// TODO: consider a more efficient implementation that directly gets the last one from the content repository
|
// TODO: consider a more efficient implementation that directly gets the last one from the content repository
|
||||||
|
@ -61,11 +70,12 @@ public class DefaultRepositoryStatisticsManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void walkRepository( RepositoryStatistics stats, String repositoryId, String ns )
|
private void walkRepository( RepositoryStatistics stats, String repositoryId, String ns,
|
||||||
|
ManagedRepositoryContent repositoryContent )
|
||||||
{
|
{
|
||||||
for ( String namespace : metadataRepository.getNamespaces( repositoryId, ns ) )
|
for ( String namespace : metadataRepository.getNamespaces( repositoryId, ns ) )
|
||||||
{
|
{
|
||||||
walkRepository( stats, repositoryId, ns + "." + namespace );
|
walkRepository( stats, repositoryId, ns + "." + namespace, repositoryContent );
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> projects = metadataRepository.getProjects( repositoryId, ns );
|
Collection<String> projects = metadataRepository.getProjects( repositoryId, ns );
|
||||||
|
@ -84,7 +94,18 @@ public class DefaultRepositoryStatisticsManager
|
||||||
stats.setTotalArtifactCount( stats.getTotalArtifactCount() + 1 );
|
stats.setTotalArtifactCount( stats.getTotalArtifactCount() + 1 );
|
||||||
stats.setTotalArtifactFileSize( stats.getTotalArtifactFileSize() + artifact.getSize() );
|
stats.setTotalArtifactFileSize( stats.getTotalArtifactFileSize() + artifact.getSize() );
|
||||||
|
|
||||||
// TODO: add by type
|
// TODO: need a maven2 metadata repository API equivalent
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String type = repositoryContent.toArtifactReference(
|
||||||
|
ns.replace( '.', '/' ) + "/" + project + "/" + version + "/" +
|
||||||
|
artifact.getId() ).getType();
|
||||||
|
stats.setTotalCountForType( type, stats.getTotalCountForType( type ) + 1 );
|
||||||
|
}
|
||||||
|
catch ( LayoutException e )
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +113,8 @@ public class DefaultRepositoryStatisticsManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addStatisticsAfterScan( String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles )
|
public void addStatisticsAfterScan( String repositoryId, Date startTime, Date endTime, long totalFiles,
|
||||||
|
long newFiles )
|
||||||
{
|
{
|
||||||
RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
|
RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
|
||||||
repositoryStatistics.setScanStartTime( startTime );
|
repositoryStatistics.setScanStartTime( startTime );
|
||||||
|
@ -112,7 +134,16 @@ public class DefaultRepositoryStatisticsManager
|
||||||
// it on the fly
|
// it on the fly
|
||||||
for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) )
|
for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) )
|
||||||
{
|
{
|
||||||
walkRepository( repositoryStatistics, repositoryId, ns );
|
ManagedRepositoryContent content;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
content = repositoryContentFactory.getManagedRepositoryContent( repositoryId );
|
||||||
|
}
|
||||||
|
catch ( RepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
walkRepository( repositoryStatistics, repositoryId, ns, content );
|
||||||
}
|
}
|
||||||
log.info( "Repository walk for statistics executed in " + ( System.currentTimeMillis() - startWalk ) + "ms" );
|
log.info( "Repository walk for statistics executed in " + ( System.currentTimeMillis() - startWalk ) + "ms" );
|
||||||
|
|
||||||
|
@ -157,4 +188,9 @@ public class DefaultRepositoryStatisticsManager
|
||||||
{
|
{
|
||||||
this.metadataRepository = metadataRepository;
|
this.metadataRepository = metadataRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRepositoryContentFactory( RepositoryContentFactory repositoryContentFactory )
|
||||||
|
{
|
||||||
|
this.repositoryContentFactory = repositoryContentFactory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class RepositoryStatistics
|
||||||
|
|
||||||
static final DateFormat SCAN_TIMESTAMP = new SimpleDateFormat( "yyyyMMdd.HHmmss.SSS" );
|
static final DateFormat SCAN_TIMESTAMP = new SimpleDateFormat( "yyyyMMdd.HHmmss.SSS" );
|
||||||
|
|
||||||
|
private Map<String, Long> totalCountForType = new HashMap<String, Long>();
|
||||||
|
|
||||||
public Date getScanEndTime()
|
public Date getScanEndTime()
|
||||||
{
|
{
|
||||||
return scanEndTime;
|
return scanEndTime;
|
||||||
|
@ -156,6 +158,10 @@ public class RepositoryStatistics
|
||||||
properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) );
|
properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) );
|
||||||
properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) );
|
properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) );
|
||||||
properties.put( "newFileCount", String.valueOf( newFileCount ) );
|
properties.put( "newFileCount", String.valueOf( newFileCount ) );
|
||||||
|
for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() )
|
||||||
|
{
|
||||||
|
properties.put( "count-" + entry.getKey(), String.valueOf( entry.getValue() ) );
|
||||||
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,15 +175,14 @@ public class RepositoryStatistics
|
||||||
totalGroupCount = Long.valueOf( properties.get( "totalGroupCount" ) );
|
totalGroupCount = Long.valueOf( properties.get( "totalGroupCount" ) );
|
||||||
totalProjectCount = Long.valueOf( properties.get( "totalProjectCount" ) );
|
totalProjectCount = Long.valueOf( properties.get( "totalProjectCount" ) );
|
||||||
newFileCount = Long.valueOf( properties.get( "newFileCount" ) );
|
newFileCount = Long.valueOf( properties.get( "newFileCount" ) );
|
||||||
}
|
totalCountForType.clear();
|
||||||
|
for ( Map.Entry<String, String> entry : properties.entrySet() )
|
||||||
@Override
|
{
|
||||||
public String toString()
|
if ( entry.getKey().startsWith( "count-" ) )
|
||||||
{
|
{
|
||||||
return "RepositoryStatistics{" + "scanEndTime=" + scanEndTime + ", scanStartTime=" + scanStartTime +
|
totalCountForType.put( entry.getKey().substring( 6 ), Long.valueOf( entry.getValue() ) );
|
||||||
", totalArtifactCount=" + totalArtifactCount + ", totalArtifactFileSize=" + totalArtifactFileSize +
|
}
|
||||||
", totalFileCount=" + totalFileCount + ", totalGroupCount=" + totalGroupCount + ", totalProjectCount=" +
|
}
|
||||||
totalProjectCount + ", newFileCount=" + newFileCount + '}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -226,6 +231,10 @@ public class RepositoryStatistics
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ( !totalCountForType.equals( that.totalCountForType ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -241,6 +250,32 @@ public class RepositoryStatistics
|
||||||
result = 31 * result + (int) ( totalGroupCount ^ ( totalGroupCount >>> 32 ) );
|
result = 31 * result + (int) ( totalGroupCount ^ ( totalGroupCount >>> 32 ) );
|
||||||
result = 31 * result + (int) ( totalProjectCount ^ ( totalProjectCount >>> 32 ) );
|
result = 31 * result + (int) ( totalProjectCount ^ ( totalProjectCount >>> 32 ) );
|
||||||
result = 31 * result + (int) ( newFileCount ^ ( newFileCount >>> 32 ) );
|
result = 31 * result + (int) ( newFileCount ^ ( newFileCount >>> 32 ) );
|
||||||
|
result = 31 * result + totalCountForType.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "RepositoryStatistics{" + "scanEndTime=" + scanEndTime + ", scanStartTime=" + scanStartTime +
|
||||||
|
", totalArtifactCount=" + totalArtifactCount + ", totalArtifactFileSize=" + totalArtifactFileSize +
|
||||||
|
", totalFileCount=" + totalFileCount + ", totalGroupCount=" + totalGroupCount + ", totalProjectCount=" +
|
||||||
|
totalProjectCount + ", newFileCount=" + newFileCount + ", totalCountForType=" + totalCountForType + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Long> getTotalCountForType()
|
||||||
|
{
|
||||||
|
return totalCountForType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalCountForType( String type )
|
||||||
|
{
|
||||||
|
Long value = totalCountForType.get( type );
|
||||||
|
return value != null ? value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalCountForType( String type, long count )
|
||||||
|
{
|
||||||
|
totalCountForType.put( type, count );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,11 @@ import java.util.Map;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||||
import org.apache.archiva.metadata.repository.MetadataRepository;
|
import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||||
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
|
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
||||||
import org.easymock.MockControl;
|
import org.easymock.MockControl;
|
||||||
|
import org.easymock.classextension.MockClassControl;
|
||||||
|
|
||||||
public class RepositoryStatisticsManagerTest
|
public class RepositoryStatisticsManagerTest
|
||||||
extends TestCase
|
extends TestCase
|
||||||
|
@ -61,6 +65,18 @@ public class RepositoryStatisticsManagerTest
|
||||||
metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
|
metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
|
||||||
metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
|
metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
|
||||||
repositoryStatisticsManager.setMetadataRepository( metadataRepository );
|
repositoryStatisticsManager.setMetadataRepository( metadataRepository );
|
||||||
|
|
||||||
|
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
|
||||||
|
repository.setId( TEST_REPO_ID );
|
||||||
|
repository.setLocation( "" );
|
||||||
|
ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent();
|
||||||
|
content.setRepository( repository );
|
||||||
|
MockControl control = MockClassControl.createControl( RepositoryContentFactory.class );
|
||||||
|
RepositoryContentFactory contentFactory = (RepositoryContentFactory) control.getMock();
|
||||||
|
contentFactory.getManagedRepositoryContent( TEST_REPO_ID );
|
||||||
|
control.setDefaultReturnValue( content );
|
||||||
|
control.replay();
|
||||||
|
repositoryStatisticsManager.setRepositoryContentFactory( contentFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLatestStats()
|
public void testGetLatestStats()
|
||||||
|
|
Loading…
Reference in New Issue