when( repositorySession.getRepository() ).thenReturn( repo );
TestRepositorySessionFactory repositorySessionFactory =
applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
repositorySessionFactory.setRepositorySession( repositorySession );
RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
action.setRepositoryFactory( factory );
ManagedRepository config = new ManagedRepository();
config.setId( TEST_REPO );
config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
content.setRepository( config );
when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
Configuration configuration = new Configuration();
configuration.addManagedRepository(
new BeanReplicator().replicateBean( config, ManagedRepositoryConfiguration.class ) );
when( archivaConfig.getConfiguration() ).thenReturn( configuration );
when( factory.getArchivaConfiguration() ).thenReturn( archivaConfig );
}