@Test public void fromProperties( ) throws Exception { DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics( ); Date startTime = new Date(); Date endTime = new Date(); Map<String,String> props = new HashMap<>( ); props.put("totalFileCount","501"); props.put("newFileCount","11"); props.put("totalArtifactCount","301"); props.put("totalArtifactFileSize","473565557"); props.put("totalGroupCount","5"); props.put("totalProjectCount","7"); props.put("count-custom-test.value.1","56"); props.put("count-custom-test.value.2","45"); props.put("count-type-java-source","14"); props.put("count-type-pom","6"); props.put("scanStartTime", String.valueOf(startTime.getTime())); props.put("scanEndTime", String.valueOf(endTime.getTime())); stats.fromProperties( props ); assertEquals(501,stats.getTotalFileCount()); assertEquals(11,stats.getNewFileCount()); assertEquals(301, stats.getTotalArtifactCount()); assertEquals(473565557, stats.getTotalArtifactFileSize()); assertEquals(5, stats.getTotalGroupCount()); assertEquals(7, stats.getTotalProjectCount()); assertEquals(56, stats.getCustomValue( "test.value.1" )); assertEquals(45, stats.getCustomValue( "test.value.2" )); assertEquals(14, stats.getTotalCountForType( "java-source" )); assertEquals(6, stats.getTotalCountForType( "pom" )); assertEquals(startTime, stats.getScanStartTime()); assertEquals( endTime, stats.getScanEndTime() ); }
@Override public void fromProperties( Map<String, String> properties ) { scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry<String, String> entry : properties.entrySet() ) { if ( entry.getKey().startsWith( TYPE_PREFIX ) ) { totalCountForType.put( entry.getKey().substring( TYPE_PREFIX.length() ), Long.valueOf( entry.getValue() ) ); } else if (entry.getKey().startsWith( CUSTOM_PREFIX )) { if (customValues==null) { createCustomValueMap(); } customValues.put(entry.getKey().substring( CUSTOM_PREFIX.length() ), Long.valueOf(entry.getValue())); } } }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public void fromProperties( Map<String, String> properties ) { scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry<String, String> entry : properties.entrySet() ) { if ( entry.getKey().startsWith( TYPE_PREFIX ) ) { totalCountForType.put( entry.getKey().substring( TYPE_PREFIX.length() ), Long.valueOf( entry.getValue() ) ); } else if (entry.getKey().startsWith( CUSTOM_PREFIX )) { if (customValues==null) { createCustomValueMap(); } customValues.put(entry.getKey().substring( CUSTOM_PREFIX.length() ), Long.valueOf(entry.getValue())); } } } }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public void fromProperties( Map<String, String> properties ) { scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry<String, String> entry : properties.entrySet() ) { if ( entry.getKey().startsWith( TYPE_PREFIX ) ) { totalCountForType.put( entry.getKey().substring( TYPE_PREFIX.length() ), Long.valueOf( entry.getValue() ) ); } else if (entry.getKey().startsWith( CUSTOM_PREFIX )) { if (customValues==null) { createCustomValueMap(); } customValues.put(entry.getKey().substring( CUSTOM_PREFIX.length() ), Long.valueOf(entry.getValue())); } } }  }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public void fromProperties( Map<String, String> properties ) { scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry<String, String> entry : properties.entrySet() ) { if ( entry.getKey().startsWith( TYPE_PREFIX ) ) { totalCountForType.put( entry.getKey().substring( TYPE_PREFIX.length() ), Long.valueOf( entry.getValue() ) ); } else if (entry.getKey().startsWith( CUSTOM_PREFIX )) { if (customValues==null) { createCustomValueMap(); } customValues.put(entry.getKey().substring( CUSTOM_PREFIX.length() ), Long.valueOf(entry.getValue())); } } }  @Override Date getScanEndTime( ); void setScanEndTime( Date scanEndTime ); @Override Date getScanStartTime( ); void setScanStartTime( Date scanStartTime ); @Override long getTotalArtifactCount( ); @Override void setTotalArtifactCount( long totalArtifactCount ); @Override long getTotalArtifactFileSize( ); @Override void setTotalArtifactFileSize( long totalArtifactFileSize ); @Override long getTotalFileCount( ); @Override void setTotalFileCount( long totalFileCount ); @Override long getTotalGroupCount( ); @Override void setTotalGroupCount( long totalGroupCount ); @Override long getTotalProjectCount( ); @Override void setTotalProjectCount( long totalProjectCount ); @Override void setNewFileCount( long newFileCount ); @Override long getNewFileCount( ); @Override long getDuration( ); @Override String getRepositoryId( ); void setRepositoryId( String repositoryId ); @Override String getFacetId(); @Override String getName(); @Override Map<String, String> toProperties(); @Override void fromProperties( Map<String, String> properties ); @Override boolean equals( Object o ); @Override int hashCode(); @Override String toString(); @Override Map<String, Long> getTotalCountForType( ); @Override long getTotalCountForType( String type ); @Override void setTotalCountForType( String type, long count ); @Override long getCustomValue( String fieldName ); @Override void setCustomValue( String fieldName, long count ); }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public void fromProperties( Map<String, String> properties ) { scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry<String, String> entry : properties.entrySet() ) { if ( entry.getKey().startsWith( TYPE_PREFIX ) ) { totalCountForType.put( entry.getKey().substring( TYPE_PREFIX.length() ), Long.valueOf( entry.getValue() ) ); } else if (entry.getKey().startsWith( CUSTOM_PREFIX )) { if (customValues==null) { createCustomValueMap(); } customValues.put(entry.getKey().substring( CUSTOM_PREFIX.length() ), Long.valueOf(entry.getValue())); } } }  @Override Date getScanEndTime( ); void setScanEndTime( Date scanEndTime ); @Override Date getScanStartTime( ); void setScanStartTime( Date scanStartTime ); @Override long getTotalArtifactCount( ); @Override void setTotalArtifactCount( long totalArtifactCount ); @Override long getTotalArtifactFileSize( ); @Override void setTotalArtifactFileSize( long totalArtifactFileSize ); @Override long getTotalFileCount( ); @Override void setTotalFileCount( long totalFileCount ); @Override long getTotalGroupCount( ); @Override void setTotalGroupCount( long totalGroupCount ); @Override long getTotalProjectCount( ); @Override void setTotalProjectCount( long totalProjectCount ); @Override void setNewFileCount( long newFileCount ); @Override long getNewFileCount( ); @Override long getDuration( ); @Override String getRepositoryId( ); void setRepositoryId( String repositoryId ); @Override String getFacetId(); @Override String getName(); @Override Map<String, String> toProperties(); @Override void fromProperties( Map<String, String> properties ); @Override boolean equals( Object o ); @Override int hashCode(); @Override String toString(); @Override Map<String, Long> getTotalCountForType( ); @Override long getTotalCountForType( String type ); @Override void setTotalCountForType( String type, long count ); @Override long getCustomValue( String fieldName ); @Override void setCustomValue( String fieldName, long count ); static final String SCAN_TIMESTAMP_FORMAT; static final String TYPE_PREFIX; static final String CUSTOM_PREFIX; }