mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Remove special RepositoryNotFoundException
This commit is contained in:
@@ -10,7 +10,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.api.CatCommandBuilder;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
@@ -58,7 +57,7 @@ public class ContentResourceTest {
|
||||
when(catCommand.setRevision(REV)).thenReturn(catCommand);
|
||||
|
||||
// defaults for unknown things
|
||||
doThrow(new RepositoryNotFoundException("x")).when(repositoryServiceFactory).create(not(eq(existingNamespaceAndName)));
|
||||
doThrow(new NotFoundException("Test", "r")).when(repositoryServiceFactory).create(not(eq(existingNamespaceAndName)));
|
||||
doThrow(new NotFoundException("Test", "X")).when(catCommand).getStream(any());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import sonia.scm.NotFoundException;
|
||||
import sonia.scm.api.rest.AuthorizationExceptionMapper;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.api.DiffCommandBuilder;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
@@ -107,7 +106,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGet404OnMissingRepository() throws URISyntaxException, RepositoryNotFoundException {
|
||||
public void shouldGet404OnMissingRepository() throws URISyntaxException {
|
||||
when(serviceFactory.create(any(NamespaceAndName.class))).thenThrow(new NotFoundException("Text", "x"));
|
||||
MockHttpRequest request = MockHttpRequest
|
||||
.get(DIFF_URL + "revision")
|
||||
|
||||
@@ -26,7 +26,6 @@ import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.api.LogCommandBuilder;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
@@ -133,7 +132,7 @@ public class FileHistoryResourceTest extends RepositoryTestBase {
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldGet404OnMissingRepository() throws URISyntaxException, RepositoryNotFoundException {
|
||||
public void shouldGet404OnMissingRepository() throws URISyntaxException {
|
||||
when(serviceFactory.create(any(NamespaceAndName.class))).thenThrow(new NotFoundException("Text", "x"));
|
||||
MockHttpRequest request = MockHttpRequest
|
||||
.get(FILE_HISTORY_URL + "revision/a.txt")
|
||||
|
||||
@@ -10,10 +10,10 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.api.BrowseCommandBuilder;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
@@ -81,8 +81,8 @@ public class SourceRootResourceTest extends RepositoryTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturn404IfRepoNotFound() throws URISyntaxException, RepositoryNotFoundException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(new RepositoryNotFoundException("abc"));
|
||||
public void shouldReturn404IfRepoNotFound() throws URISyntaxException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(new NotFoundException("Test", "a"));
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "idont/exist/sources");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
@@ -109,8 +109,8 @@ public class SourceRootResourceTest extends RepositoryTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGet404ForSingleFileIfRepoNotFound() throws URISyntaxException, RepositoryNotFoundException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(new RepositoryNotFoundException("abc"));
|
||||
public void shouldGet404ForSingleFileIfRepoNotFound() throws URISyntaxException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(new NotFoundException("Test", "a"));
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "idont/exist/sources/revision/fileabc");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
@@ -353,7 +353,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository> {
|
||||
manager.refresh(heartOfGold);
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryNotFoundException.class)
|
||||
@Test(expected = NotFoundException.class)
|
||||
public void testRefreshNotFound(){
|
||||
manager.refresh(createRepositoryWithId());
|
||||
}
|
||||
@@ -383,7 +383,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository> {
|
||||
RepositoryManager repoManager = createRepositoryManager(false);
|
||||
Repository repository = spy(createTestRepository());
|
||||
repository.setName("Testrepo");
|
||||
((DefaultRepositoryManager) repoManager).create(repository);
|
||||
repoManager.create(repository);
|
||||
assertEquals("default_namespace", repository.getNamespace());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.PushStateDispatcher;
|
||||
import sonia.scm.repository.DefaultRepositoryProvider;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.repository.spi.HttpScmProtocol;
|
||||
@@ -58,12 +58,12 @@ public class HttpProtocolServletTest {
|
||||
private HttpScmProtocol protocol;
|
||||
|
||||
@Before
|
||||
public void init() throws RepositoryNotFoundException {
|
||||
public void init() {
|
||||
initMocks(this);
|
||||
when(userAgentParser.parse(request)).thenReturn(userAgent);
|
||||
when(userAgent.isBrowser()).thenReturn(false);
|
||||
NamespaceAndName existingRepo = new NamespaceAndName("space", "repo");
|
||||
when(serviceFactory.create(not(eq(existingRepo)))).thenThrow(new RepositoryNotFoundException("x"));
|
||||
when(serviceFactory.create(not(eq(existingRepo)))).thenThrow(new NotFoundException("Test", "a"));
|
||||
when(serviceFactory.create(existingRepo)).thenReturn(repositoryService);
|
||||
when(requestProvider.get()).thenReturn(httpServletRequest);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class HttpProtocolServletTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDelegateToProvider() throws RepositoryNotFoundException, IOException, ServletException {
|
||||
public void shouldDelegateToProvider() throws IOException, ServletException {
|
||||
when(request.getPathInfo()).thenReturn("/space/name");
|
||||
NamespaceAndName namespaceAndName = new NamespaceAndName("space", "name");
|
||||
doReturn(repositoryService).when(serviceFactory).create(namespaceAndName);
|
||||
|
||||
Reference in New Issue
Block a user