### Question:
UnifiedRepositoryPurgeService implements IPurgeService { public void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ) throws PurgeDeletionException { if ( purgeSpecification != null ) { getLogger().setCurrentFilePath( purgeSpecification.getPath() ); logConfiguration( purgeSpecification ); if ( purgeSpecification.getPath() != null && !purgeSpecification.getPath().isEmpty() ) { processRevisionDeletion( purgeSpecification ); } if ( purgeSpecification.isSharedObjects() ) { if ( purgeSpecification.isPurgeFiles() ) { for ( String sharedObjectpath : sharedObjectFolders ) { purgeSpecification.fileFilter = "*"; purgeSpecification.setPath( sharedObjectpath ); processRevisionDeletion( purgeSpecification ); } } else { throw new PurgeDeletionException( "Must purge files before shared objects" ); } } } } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepository ); @Override void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ); @Override void deleteVersionsBeforeDate( Serializable fileId, Date beforeDate ); @Override void deleteAllVersions( RepositoryElementInterface element ); @Override void deleteAllVersions( Serializable fileId ); @Override void deleteVersion( RepositoryElementInterface element, String versionId ); @Override void deleteVersion( Serializable fileId, Serializable versionId ); @Override void keepNumberOfVersions( RepositoryElementInterface element, int versionCount ); @Override void keepNumberOfVersions( Serializable fileId, int versionCount ); void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ); static DefaultUnifiedRepositoryWebService getRepoWs(); static DefaultUnifiedRepositoryWebService repoWs; }### Answer:
@Test public void doPurgeUtilVersionCountTest() throws PurgeDeletionException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = getPurgeService( mockRepo ); PurgeUtilitySpecification spec = new PurgeUtilitySpecification(); spec.setVersionCount( 3 ); spec.setPath( "/" ); purgeService.doDeleteRevisions( spec ); verifyVersionCountDeletion( versionListMap, mockRepo, "1", spec.getVersionCount() ); verifyVersionCountDeletion( versionListMap, mockRepo, "2", spec.getVersionCount() ); }
@Test public void doPurgeUtilDateBeforeTest() throws PurgeDeletionException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = getPurgeService( mockRepo ); PurgeUtilitySpecification spec = new PurgeUtilitySpecification(); spec.setBeforeDate( getDate( "01/02/2006" ) ); spec.setPath( "/" ); purgeService.doDeleteRevisions( spec ); verifyDateBeforeDeletion( versionListMap, mockRepo, "1", spec.getBeforeDate() ); verifyDateBeforeDeletion( versionListMap, mockRepo, "2", spec.getBeforeDate() ); }