@Test public void toProperties( ) throws Exception { DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics(); Date startTime = new Date(); Date endTime = new Date(); stats.setScanStartTime( startTime ); stats.setScanEndTime( endTime ); stats.setTotalFileCount( 500 ); stats.setNewFileCount( 10 ); stats.setRepositoryId( "test-repo" ); stats.setTotalArtifactCount( 300 ); stats.setTotalArtifactFileSize( 4848484 ); stats.setTotalGroupCount( 4 ); stats.setTotalProjectCount( 6 ); stats.setCustomValue( "test.value.1", 55 ); stats.setCustomValue( "test.value.2", 44); stats.setTotalCountForType( "java-source",13 ); stats.setTotalCountForType( "pom", 5 ); Map<String, String> props = stats.toProperties( ); assertEquals( "500", props.get("totalFileCount") ); assertEquals( "10", props.get("newFileCount")); assertEquals( "300", props.get("totalArtifactCount")); assertEquals( "4848484", props.get("totalArtifactFileSize")); assertEquals("4", props.get("totalGroupCount")); assertEquals("6", props.get("totalProjectCount")); assertEquals("55",props.get("count-custom-test.value.1" )); assertEquals("44", props.get("count-custom-test.value.2")); assertEquals("13", props.get("count-type-java-source")); assertEquals("5", props.get("count-type-pom")); assertEquals( String.valueOf(startTime.getTime()), props.get("scanStartTime")); assertEquals( String.valueOf(endTime.getTime()), props.get("scanEndTime")); }
@Override public Map<String, String> toProperties() { Map<String, String> properties = new HashMap<>(); if (scanEndTime==null) { properties.put("scanEndTime", "0"); } else { properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime( ) ) ); } if (scanStartTime==null) { properties.put("scanStartTime","0"); } else { properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime( ) ) ); } properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); properties.put( "repositoryId", repositoryId ); for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) { properties.put( TYPE_PREFIX + entry.getKey(), String.valueOf( entry.getValue() ) ); } if (customValues!=null) { for (Map.Entry<String, Long> entry : customValues.entrySet()) { properties.put(CUSTOM_PREFIX+entry.getKey(), String.valueOf(entry.getValue())); } } return properties; }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public Map<String, String> toProperties() { Map<String, String> properties = new HashMap<>(); if (scanEndTime==null) { properties.put("scanEndTime", "0"); } else { properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime( ) ) ); } if (scanStartTime==null) { properties.put("scanStartTime","0"); } else { properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime( ) ) ); } properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); properties.put( "repositoryId", repositoryId ); for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) { properties.put( TYPE_PREFIX + entry.getKey(), String.valueOf( entry.getValue() ) ); } if (customValues!=null) { for (Map.Entry<String, Long> entry : customValues.entrySet()) { properties.put(CUSTOM_PREFIX+entry.getKey(), String.valueOf(entry.getValue())); } } return properties; } }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public Map<String, String> toProperties() { Map<String, String> properties = new HashMap<>(); if (scanEndTime==null) { properties.put("scanEndTime", "0"); } else { properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime( ) ) ); } if (scanStartTime==null) { properties.put("scanStartTime","0"); } else { properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime( ) ) ); } properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); properties.put( "repositoryId", repositoryId ); for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) { properties.put( TYPE_PREFIX + entry.getKey(), String.valueOf( entry.getValue() ) ); } if (customValues!=null) { for (Map.Entry<String, Long> entry : customValues.entrySet()) { properties.put(CUSTOM_PREFIX+entry.getKey(), String.valueOf(entry.getValue())); } } return properties; }  }
DefaultRepositoryStatistics implements RepositoryStatistics { @Override public Map<String, String> toProperties() { Map<String, String> properties = new HashMap<>(); if (scanEndTime==null) { properties.put("scanEndTime", "0"); } else { properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime( ) ) ); } if (scanStartTime==null) { properties.put("scanStartTime","0"); } else { properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime( ) ) ); } properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); properties.put( "repositoryId", repositoryId ); for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) { properties.put( TYPE_PREFIX + entry.getKey(), String.valueOf( entry.getValue() ) ); } if (customValues!=null) { for (Map.Entry<String, Long> entry : customValues.entrySet()) { properties.put(CUSTOM_PREFIX+entry.getKey(), String.valueOf(entry.getValue())); } } return properties; }  @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 Map<String, String> toProperties() { Map<String, String> properties = new HashMap<>(); if (scanEndTime==null) { properties.put("scanEndTime", "0"); } else { properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime( ) ) ); } if (scanStartTime==null) { properties.put("scanStartTime","0"); } else { properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime( ) ) ); } properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); properties.put( "repositoryId", repositoryId ); for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) { properties.put( TYPE_PREFIX + entry.getKey(), String.valueOf( entry.getValue() ) ); } if (customValues!=null) { for (Map.Entry<String, Long> entry : customValues.entrySet()) { properties.put(CUSTOM_PREFIX+entry.getKey(), String.valueOf(entry.getValue())); } } return properties; }  @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; }