List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
assertNotNull( repos );
int initialSize = repos.size();
assertTrue( initialSize > 0 );
ManagedRepository repo = getTestManagedRepository( repoId, repoLocation );
managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
assertTemplateRoleExists( repoId );
assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
repos = managedRepositoryAdmin.getManagedRepositories();
assertNotNull( repos );
assertEquals( initialSize + 1, repos.size() );
repo = managedRepositoryAdmin.getManagedRepository( repoId );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
String newName = "test repo update";
repo.setName( newName );
repo.setLocation( repoLocation );
managedRepositoryAdmin.updateManagedRepository( repo, true, getFakeAuditInformation(), false );
repo = managedRepositoryAdmin.getManagedRepository( repoId );
assertNotNull( repo );
assertEquals( newName, repo.getName() );
assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
assertTrue( new File( repoLocation ).exists() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getCronExpression(), repo.getCronExpression() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getLayout(), repo.getLayout() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getId(), repo.getId() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getDaysOlder(), repo.getDaysOlder() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).getRetentionCount(), repo.getRetentionCount() );
assertEquals( getTestManagedRepository( repoId, repoLocation ).isDeleteReleasedSnapshots(),
repo.isDeleteReleasedSnapshots() );
assertTemplateRoleExists( repoId );
assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
// check deleteContents false
assertTrue( repoDir.exists() );
assertTemplateRoleNotExists( repoId );