default repository manager should throw RepositoryNotFoundException

This commit is contained in:
Sebastian Sdorra
2013-01-29 20:26:38 +01:00
parent 1e7ff1a71a
commit a5c24f54d5
2 changed files with 55 additions and 15 deletions

View File

@@ -52,7 +52,7 @@ import java.util.Collection;
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public abstract class RepositoryManagerTestBase public abstract class RepositoryManagerTestBase
extends ManagerTestBase<Repository, RepositoryException> extends ManagerTestBase<Repository, RepositoryException>
{ {
/** /**
@@ -103,6 +103,19 @@ public abstract class RepositoryManagerTestBase
assertNull(manager.get(id)); assertNull(manager.get(id));
} }
/**
* Method description
*
*
* @throws IOException
* @throws RepositoryException
*/
@Test(expected = RepositoryNotFoundException.class)
public void testDeleteNotFound() throws RepositoryException, IOException
{
manager.delete(createRepositoryWithId());
}
/** /**
* Method description * Method description
* *
@@ -156,8 +169,8 @@ public abstract class RepositoryManagerTestBase
foundHeart = true; foundHeart = true;
heartReference = repository; heartReference = repository;
} }
else if (repository.getId().equals( else if (
happyVerticalPeopleTransporter.getId())) repository.getId().equals(happyVerticalPeopleTransporter.getId()))
{ {
assertRepositoriesEquals(happyVerticalPeopleTransporter, repository); assertRepositoriesEquals(happyVerticalPeopleTransporter, repository);
foundTransporter = true; foundTransporter = true;
@@ -171,7 +184,7 @@ public abstract class RepositoryManagerTestBase
assertNotSame(heartOfGold, heartReference); assertNotSame(heartOfGold, heartReference);
heartReference.setDescription("prototype ship"); heartReference.setDescription("prototype ship");
assertFalse( assertFalse(
heartOfGold.getDescription().equals(heartReference.getDescription())); heartOfGold.getDescription().equals(heartReference.getDescription()));
} }
/** /**
@@ -202,10 +215,10 @@ public abstract class RepositoryManagerTestBase
* @throws IOException * @throws IOException
* @throws RepositoryException * @throws RepositoryException
*/ */
@Test(expected = RepositoryException.class) @Test(expected = RepositoryNotFoundException.class)
public void testModifyNotExisting() throws RepositoryException, IOException public void testModifyNotFound() throws RepositoryException, IOException
{ {
manager.modify(RepositoryTestData.createHeartOfGold()); manager.modify(createRepositoryWithId());
} }
/** /**
@@ -226,6 +239,19 @@ public abstract class RepositoryManagerTestBase
assertEquals(description, heartOfGold.getDescription()); assertEquals(description, heartOfGold.getDescription());
} }
/**
* Method description
*
*
* @throws IOException
* @throws RepositoryException
*/
@Test(expected = RepositoryNotFoundException.class)
public void testRefreshNotFound() throws RepositoryException, IOException
{
manager.refresh(createRepositoryWithId());
}
/** /**
* Method description * Method description
* *
@@ -255,7 +281,7 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException * @throws RepositoryException
*/ */
private Repository createRepository(Repository repository) private Repository createRepository(Repository repository)
throws RepositoryException, IOException throws RepositoryException, IOException
{ {
manager.create(repository); manager.create(repository);
assertNotNull(repository.getId()); assertNotNull(repository.getId());
@@ -265,6 +291,21 @@ public abstract class RepositoryManagerTestBase
return repository; return repository;
} }
/**
* Method description
*
*
* @return
*/
private Repository createRepositoryWithId()
{
Repository repository = RepositoryTestData.createHeartOfGold();
repository.setId("abc");
return repository;
}
/** /**
* Method description * Method description
* *
@@ -275,10 +316,10 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException * @throws RepositoryException
*/ */
private Repository createSecondTestRepository() private Repository createSecondTestRepository()
throws RepositoryException, IOException throws RepositoryException, IOException
{ {
return createRepository( return createRepository(
RepositoryTestData.createHappyVerticalPeopleTransporter()); RepositoryTestData.createHappyVerticalPeopleTransporter());
} }
/** /**
@@ -291,7 +332,7 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException * @throws RepositoryException
*/ */
private Repository createTestRepository() private Repository createTestRepository()
throws RepositoryException, IOException throws RepositoryException, IOException
{ {
return createRepository(RepositoryTestData.createHeartOfGold()); return createRepository(RepositoryTestData.createHeartOfGold());
} }

View File

@@ -104,7 +104,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
* @param configuration * @param configuration
* @param contextProvider * @param contextProvider
* @param keyGenerator * @param keyGenerator
* @param securityContextProvider
* @param repositoryDAO * @param repositoryDAO
* @param handlerSet * @param handlerSet
* @param repositoryListenersProvider * @param repositoryListenersProvider
@@ -253,7 +252,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
} }
else else
{ {
throw new RepositoryException( throw new RepositoryNotFoundException(
"repository ".concat(repository.getName()).concat(" not found")); "repository ".concat(repository.getName()).concat(" not found"));
} }
@@ -381,7 +380,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
} }
else else
{ {
throw new RepositoryException( throw new RepositoryNotFoundException(
"repository ".concat(repository.getName()).concat(" not found")); "repository ".concat(repository.getName()).concat(" not found"));
} }
@@ -413,7 +412,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
} }
else else
{ {
throw new RepositoryException( throw new RepositoryNotFoundException(
"repository ".concat(repository.getName()).concat(" not found")); "repository ".concat(repository.getName()).concat(" not found"));
} }
} }