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
*/
public abstract class RepositoryManagerTestBase
extends ManagerTestBase<Repository, RepositoryException>
extends ManagerTestBase<Repository, RepositoryException>
{
/**
@@ -103,6 +103,19 @@ public abstract class RepositoryManagerTestBase
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
*
@@ -156,8 +169,8 @@ public abstract class RepositoryManagerTestBase
foundHeart = true;
heartReference = repository;
}
else if (repository.getId().equals(
happyVerticalPeopleTransporter.getId()))
else if (
repository.getId().equals(happyVerticalPeopleTransporter.getId()))
{
assertRepositoriesEquals(happyVerticalPeopleTransporter, repository);
foundTransporter = true;
@@ -171,7 +184,7 @@ public abstract class RepositoryManagerTestBase
assertNotSame(heartOfGold, heartReference);
heartReference.setDescription("prototype ship");
assertFalse(
heartOfGold.getDescription().equals(heartReference.getDescription()));
heartOfGold.getDescription().equals(heartReference.getDescription()));
}
/**
@@ -202,10 +215,10 @@ public abstract class RepositoryManagerTestBase
* @throws IOException
* @throws RepositoryException
*/
@Test(expected = RepositoryException.class)
public void testModifyNotExisting() throws RepositoryException, IOException
@Test(expected = RepositoryNotFoundException.class)
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());
}
/**
* Method description
*
*
* @throws IOException
* @throws RepositoryException
*/
@Test(expected = RepositoryNotFoundException.class)
public void testRefreshNotFound() throws RepositoryException, IOException
{
manager.refresh(createRepositoryWithId());
}
/**
* Method description
*
@@ -255,7 +281,7 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException
*/
private Repository createRepository(Repository repository)
throws RepositoryException, IOException
throws RepositoryException, IOException
{
manager.create(repository);
assertNotNull(repository.getId());
@@ -265,6 +291,21 @@ public abstract class RepositoryManagerTestBase
return repository;
}
/**
* Method description
*
*
* @return
*/
private Repository createRepositoryWithId()
{
Repository repository = RepositoryTestData.createHeartOfGold();
repository.setId("abc");
return repository;
}
/**
* Method description
*
@@ -275,10 +316,10 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException
*/
private Repository createSecondTestRepository()
throws RepositoryException, IOException
throws RepositoryException, IOException
{
return createRepository(
RepositoryTestData.createHappyVerticalPeopleTransporter());
RepositoryTestData.createHappyVerticalPeopleTransporter());
}
/**
@@ -291,7 +332,7 @@ public abstract class RepositoryManagerTestBase
* @throws RepositoryException
*/
private Repository createTestRepository()
throws RepositoryException, IOException
throws RepositoryException, IOException
{
return createRepository(RepositoryTestData.createHeartOfGold());
}

View File

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