FileTypes fileTypes = (FileTypes) fileTypesControl.getMock();
MockControl pathParserControl = MockClassControl.createControl( PathParser.class );
PathParser parser = (PathParser) pathParserControl.getMock();
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" );
archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent();
repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
org.apache.archiva.admin.model.beans.ManagedRepository.class ) );
repoContent.setFileTypes( fileTypes );
repoContent.setLegacyPathParser( parser );
repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
recordInManagedLegacyRepoContent( fileTypesControl, fileTypes, pathParserControl, parser );
List<ArtifactMetadata> artifacts = getArtifacts();
ArtifactMetadata artifact = artifacts.get( 0 );
metadataRepositoryControl.expectAndReturn(
metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
artifact.getVersion() ), artifacts );
metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
artifact.getVersion(), artifact.getId() );
listener.deleteArtifact( metadataRepository, repoContent.getId(), artifact.getNamespace(),
artifact.getProject(), artifact.getVersion(), artifact.getId() );
listenerControl.setVoidCallable( 1 );
archivaConfigControl.replay();
configControl.replay();
repoFactoryControl.replay();
metadataRepositoryControl.replay();
listenerControl.replay();
fileTypesControl.replay();
pathParserControl.replay();
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
assertTrue( success );
archivaConfigControl.verify();
configControl.verify();
repoFactoryControl.verify();
metadataRepositoryControl.verify();
listenerControl.verify();
fileTypesControl.verify();
pathParserControl.verify();
File repo = new File( managedRepo.getLocation() );
assertFalse( new File( repo, "org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() );
assertFalse( new File( repo, "org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() );
assertTrue( new File( repo, "org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() );
assertTrue( new File( repo, "org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() );