Commits

Sebastian Sdorra committed 5ac5983

default repository manager should throw RepositoryNotFoundException

Comments (0)

Files changed (2)

scm-test/src/main/java/sonia/scm/repository/RepositoryManagerTestBase.java

  * @author Sebastian Sdorra
  */
 public abstract class RepositoryManagerTestBase
-        extends ManagerTestBase<Repository, RepositoryException>
+  extends ManagerTestBase<Repository, RepositoryException>
 {
 
   /**
   }
 
   /**
+   * Method description
+   *
+   *
+   * @throws IOException
+   * @throws RepositoryException
+   */
+  @Test(expected = RepositoryNotFoundException.class)
+  public void testDeleteNotFound() throws RepositoryException, IOException
+  {
+    manager.delete(createRepositoryWithId());
+  }
+
+  /**
    *  Method description
    *
    *
         foundHeart = true;
         heartReference = repository;
       }
-      else if (repository.getId().equals(
-              happyVerticalPeopleTransporter.getId()))
+      else if (
+        repository.getId().equals(happyVerticalPeopleTransporter.getId()))
       {
         assertRepositoriesEquals(happyVerticalPeopleTransporter, repository);
         foundTransporter = true;
     assertNotSame(heartOfGold, heartReference);
     heartReference.setDescription("prototype ship");
     assertFalse(
-        heartOfGold.getDescription().equals(heartReference.getDescription()));
+      heartOfGold.getDescription().equals(heartReference.getDescription()));
   }
 
   /**
    * @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());
   }
 
   /**
    * Method description
    *
    *
+   * @throws IOException
+   * @throws RepositoryException
+   */
+  @Test(expected = RepositoryNotFoundException.class)
+  public void testRefreshNotFound() throws RepositoryException, IOException
+  {
+    manager.refresh(createRepositoryWithId());
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param repo
    * @param other
    */
    * @throws RepositoryException
    */
   private Repository createRepository(Repository repository)
-          throws RepositoryException, IOException
+    throws RepositoryException, IOException
   {
     manager.create(repository);
     assertNotNull(repository.getId());
    *
    *
    * @return
+   */
+  private Repository createRepositoryWithId()
+  {
+    Repository repository = RepositoryTestData.createHeartOfGold();
+
+    repository.setId("abc");
+
+    return repository;
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
    *
    * @throws IOException
    * @throws RepositoryException
    */
   private Repository createSecondTestRepository()
-          throws RepositoryException, IOException
+    throws RepositoryException, IOException
   {
     return createRepository(
-        RepositoryTestData.createHappyVerticalPeopleTransporter());
+      RepositoryTestData.createHappyVerticalPeopleTransporter());
   }
 
   /**
    * @throws RepositoryException
    */
   private Repository createTestRepository()
-          throws RepositoryException, IOException
+    throws RepositoryException, IOException
   {
     return createRepository(RepositoryTestData.createHeartOfGold());
   }

scm-webapp/src/main/java/sonia/scm/repository/DefaultRepositoryManager.java

    * @param configuration
    * @param contextProvider
    * @param keyGenerator
-   * @param securityContextProvider
    * @param repositoryDAO
    * @param handlerSet
    * @param repositoryListenersProvider
     }
     else
     {
-      throw new RepositoryException(
+      throw new RepositoryNotFoundException(
         "repository ".concat(repository.getName()).concat(" not found"));
     }
 
     }
     else
     {
-      throw new RepositoryException(
+      throw new RepositoryNotFoundException(
         "repository ".concat(repository.getName()).concat(" not found"));
     }
 
     }
     else
     {
-      throw new RepositoryException(
+      throw new RepositoryNotFoundException(
         "repository ".concat(repository.getName()).concat(" not found"));
     }
   }