mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
Replace model object exception with generic ones and migrate guice
This commit is contained in:
@@ -24,13 +24,13 @@ import static org.mockito.Mockito.when;
|
||||
public class AbstractManagerResourceTest {
|
||||
|
||||
@Mock
|
||||
private Manager<Simple, Exception> manager;
|
||||
private Manager<Simple> manager;
|
||||
@Mock
|
||||
private Request request;
|
||||
@Captor
|
||||
private ArgumentCaptor<Comparator<Simple>> comparatorCaptor;
|
||||
|
||||
private AbstractManagerResource<Simple, Exception> abstractManagerResource;
|
||||
private AbstractManagerResource<Simple> abstractManagerResource;
|
||||
|
||||
@Before
|
||||
public void captureComparator() {
|
||||
@@ -60,7 +60,7 @@ public class AbstractManagerResourceTest {
|
||||
}
|
||||
|
||||
|
||||
private class SimpleManagerResource extends AbstractManagerResource<Simple, Exception> {
|
||||
private class SimpleManagerResource extends AbstractManagerResource<Simple> {
|
||||
|
||||
{
|
||||
disableCache = true;
|
||||
|
||||
@@ -11,8 +11,6 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
@@ -20,25 +18,16 @@ import sonia.scm.security.AccessToken;
|
||||
import sonia.scm.security.AccessTokenBuilder;
|
||||
import sonia.scm.security.AccessTokenBuilderFactory;
|
||||
import sonia.scm.security.AccessTokenCookieIssuer;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserException;
|
||||
import sonia.scm.user.UserManager;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@SubjectAware(
|
||||
configuration = "classpath:sonia/scm/repository/shiro.ini"
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import sonia.scm.PageResult;
|
||||
import sonia.scm.group.Group;
|
||||
import sonia.scm.group.GroupException;
|
||||
import sonia.scm.group.GroupManager;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
@@ -27,7 +26,9 @@ import java.net.URL;
|
||||
import java.util.Collections;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
@@ -58,7 +59,7 @@ public class GroupRootResourceTest {
|
||||
private ArgumentCaptor<Group> groupCaptor = ArgumentCaptor.forClass(Group.class);
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() throws IOException, GroupException {
|
||||
public void prepareEnvironment() throws Exception {
|
||||
initMocks(this);
|
||||
when(groupManager.create(groupCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
|
||||
doNothing().when(groupManager).modify(groupCaptor.capture());
|
||||
|
||||
@@ -2,10 +2,6 @@ package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import com.google.common.io.Resources;
|
||||
import org.apache.shiro.authc.credential.PasswordService;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
@@ -16,26 +12,19 @@ import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import sonia.scm.PageResult;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserException;
|
||||
import sonia.scm.user.UserManager;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
@SubjectAware(
|
||||
@@ -64,7 +53,7 @@ public class MeResourceTest {
|
||||
private ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() throws IOException, UserException {
|
||||
public void prepareEnvironment() throws Exception {
|
||||
initMocks(this);
|
||||
createDummyUser("trillian");
|
||||
when(userManager.create(userCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.mockito.Mock;
|
||||
import sonia.scm.PageResult;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RepositoryIsNotArchivedException;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
@@ -217,7 +216,7 @@ public class RepositoryRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateNewRepositoryInCorrectNamespace() throws URISyntaxException, IOException, RepositoryException {
|
||||
public void shouldCreateNewRepositoryInCorrectNamespace() throws Exception {
|
||||
when(repositoryManager.create(any())).thenAnswer(invocation -> {
|
||||
Repository repository = (Repository) invocation.getArguments()[0];
|
||||
repository.setNamespace("otherspace");
|
||||
|
||||
@@ -16,21 +16,24 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import sonia.scm.PageResult;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserException;
|
||||
import sonia.scm.user.UserManager;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
@SubjectAware(
|
||||
@@ -59,7 +62,7 @@ public class UserRootResourceTest {
|
||||
private ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() throws UserException {
|
||||
public void prepareEnvironment() throws Exception {
|
||||
initMocks(this);
|
||||
User dummyUser = createDummyUser("Neo");
|
||||
when(userManager.create(userCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
|
||||
@@ -106,7 +109,7 @@ public class UserRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateNewUserWithEncryptedPassword() throws URISyntaxException, IOException, UserException {
|
||||
public void shouldCreateNewUserWithEncryptedPassword() throws Exception {
|
||||
URL url = Resources.getResource("sonia/scm/api/v2/user-test-create.json");
|
||||
byte[] userJson = Resources.toByteArray(url);
|
||||
|
||||
@@ -126,7 +129,7 @@ public class UserRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUpdateChangedUserWithEncryptedPassword() throws URISyntaxException, IOException, UserException {
|
||||
public void shouldUpdateChangedUserWithEncryptedPassword() throws Exception {
|
||||
URL url = Resources.getResource("sonia/scm/api/v2/user-test-update.json");
|
||||
byte[] userJson = Resources.toByteArray(url);
|
||||
|
||||
@@ -170,7 +173,7 @@ public class UserRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteUser() throws URISyntaxException, IOException, UserException {
|
||||
public void shouldDeleteUser() throws Exception {
|
||||
MockHttpRequest request = MockHttpRequest.delete("/" + UserRootResource.USERS_PATH_V2 + "Neo");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
@@ -181,7 +184,7 @@ public class UserRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFailUpdateForDifferentIds() throws IOException, URISyntaxException, UserException {
|
||||
public void shouldFailUpdateForDifferentIds() throws Exception {
|
||||
URL url = Resources.getResource("sonia/scm/api/v2/user-test-update.json");
|
||||
byte[] userJson = Resources.toByteArray(url);
|
||||
createDummyUser("Other");
|
||||
@@ -199,7 +202,7 @@ public class UserRootResourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFailUpdateForUnknownEntity() throws IOException, URISyntaxException, UserException {
|
||||
public void shouldFailUpdateForUnknownEntity() throws Exception {
|
||||
URL url = Resources.getResource("sonia/scm/api/v2/user-test-update.json");
|
||||
byte[] userJson = Resources.toByteArray(url);
|
||||
when(userManager.get("Neo")).thenReturn(null);
|
||||
|
||||
@@ -34,28 +34,24 @@ package sonia.scm.cache;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.CharSource;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static java.util.Collections.emptyIterator;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -196,7 +192,7 @@ public class CacheConfigurationTestLoader implements CacheConfigurationLoader
|
||||
|
||||
if (moduleConfigurations == null)
|
||||
{
|
||||
urlIterator = Iterators.emptyIterator();
|
||||
urlIterator = emptyIterator();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -43,7 +43,11 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import sonia.scm.*;
|
||||
import sonia.scm.AlreadyExistsException;
|
||||
import sonia.scm.HandlerEventType;
|
||||
import sonia.scm.Manager;
|
||||
import sonia.scm.ManagerTestBase;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.event.ScmEventBus;
|
||||
import sonia.scm.repository.api.HookContext;
|
||||
@@ -56,9 +60,15 @@ import sonia.scm.security.KeyGenerator;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
import sonia.scm.store.JAXBConfigurationStoreFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -83,7 +93,7 @@ import static org.mockito.Mockito.when;
|
||||
password = "secret",
|
||||
configuration = "classpath:sonia/scm/repository/shiro.ini"
|
||||
)
|
||||
public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, RepositoryException> {
|
||||
public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository> {
|
||||
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
@@ -96,7 +106,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
private String mockedNamespace = "default_namespace";
|
||||
|
||||
@Test
|
||||
public void testCreate() throws RepositoryException {
|
||||
public void testCreate() throws AlreadyExistsException {
|
||||
Repository heartOfGold = createTestRepository();
|
||||
Repository dbRepo = manager.get(heartOfGold.getId());
|
||||
|
||||
@@ -108,18 +118,18 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
username = "unpriv"
|
||||
)
|
||||
@Test(expected = UnauthorizedException.class)
|
||||
public void testCreateWithoutPrivileges() throws RepositoryException {
|
||||
public void testCreateWithoutPrivileges() throws AlreadyExistsException {
|
||||
createTestRepository();
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryAlreadyExistsException.class)
|
||||
public void testCreateExisting() throws RepositoryException {
|
||||
@Test(expected = AlreadyExistsException.class)
|
||||
public void testCreateExisting() throws AlreadyExistsException {
|
||||
createTestRepository();
|
||||
createTestRepository();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws RepositoryException {
|
||||
public void testDelete() throws Exception {
|
||||
delete(manager, createTestRepository());
|
||||
}
|
||||
|
||||
@@ -127,24 +137,23 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
username = "unpriv"
|
||||
)
|
||||
@Test(expected = UnauthorizedException.class)
|
||||
public void testDeleteWithoutPrivileges() throws RepositoryException {
|
||||
public void testDeleteWithoutPrivileges() throws Exception {
|
||||
delete(manager, createTestRepository());
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryIsNotArchivedException.class)
|
||||
public void testDeleteNonArchived() throws RepositoryException {
|
||||
public void testDeleteNonArchived() throws Exception {
|
||||
configuration.setEnableRepositoryArchive(true);
|
||||
delete(manager, createTestRepository());
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryNotFoundException.class)
|
||||
public void testDeleteNotFound() throws RepositoryException {
|
||||
@Test(expected = NotFoundException.class)
|
||||
public void testDeleteNotFound() throws NotFoundException {
|
||||
manager.delete(createRepositoryWithId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteWithEnabledArchive()
|
||||
throws RepositoryException {
|
||||
public void testDeleteWithEnabledArchive() throws Exception {
|
||||
Repository repository = createTestRepository();
|
||||
|
||||
repository.setArchived(true);
|
||||
@@ -154,7 +163,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws RepositoryException {
|
||||
public void testGet() throws AlreadyExistsException {
|
||||
Repository heartOfGold = createTestRepository();
|
||||
String id = heartOfGold.getId();
|
||||
String description = heartOfGold.getDescription();
|
||||
@@ -172,7 +181,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
@SubjectAware(
|
||||
username = "crato"
|
||||
)
|
||||
public void testGetWithoutRequiredPrivileges() throws RepositoryException {
|
||||
public void testGetWithoutRequiredPrivileges() throws AlreadyExistsException {
|
||||
Repository heartOfGold = RepositoryTestData.createHeartOfGold();
|
||||
manager.create(heartOfGold);
|
||||
|
||||
@@ -181,7 +190,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAll() throws RepositoryException {
|
||||
public void testGetAll() throws AlreadyExistsException {
|
||||
Repository heartOfGold = createTestRepository();
|
||||
Repository happyVerticalPeopleTransporter = createSecondTestRepository();
|
||||
boolean foundHeart = false;
|
||||
@@ -219,7 +228,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
@SubjectAware(username = "dent")
|
||||
public void testGetAllWithPermissionsForTwoOrThreeRepos() throws RepositoryException {
|
||||
public void testGetAllWithPermissionsForTwoOrThreeRepos() throws AlreadyExistsException {
|
||||
// mock key generator
|
||||
KeyGenerator keyGenerator = mock(KeyGenerator.class);
|
||||
Stack<String> keys = new Stack<>();
|
||||
@@ -260,7 +269,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEvents() throws RepositoryException {
|
||||
public void testEvents() throws Exception {
|
||||
RepositoryManager repoManager = createRepositoryManager(false);
|
||||
repoManager.init(contextProvider);
|
||||
TestListener listener = new TestListener();
|
||||
@@ -291,7 +300,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModify() throws RepositoryException {
|
||||
public void testModify() throws NotFoundException, AlreadyExistsException {
|
||||
Repository heartOfGold = createTestRepository();
|
||||
|
||||
heartOfGold.setDescription("prototype ship");
|
||||
@@ -305,7 +314,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "crato")
|
||||
public void testModifyWithoutRequiredPermissions() throws RepositoryException {
|
||||
public void testModifyWithoutRequiredPermissions() throws AlreadyExistsException, NotFoundException {
|
||||
Repository heartOfGold = RepositoryTestData.createHeartOfGold();
|
||||
manager.create(heartOfGold);
|
||||
heartOfGold.setDescription("prototype ship");
|
||||
@@ -314,13 +323,13 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
manager.modify(heartOfGold);
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryNotFoundException.class)
|
||||
public void testModifyNotFound() throws RepositoryException {
|
||||
@Test(expected = NotFoundException.class)
|
||||
public void testModifyNotFound() throws NotFoundException {
|
||||
manager.modify(createRepositoryWithId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefresh() throws RepositoryException {
|
||||
public void testRefresh() throws NotFoundException, AlreadyExistsException {
|
||||
Repository heartOfGold = createTestRepository();
|
||||
String description = heartOfGold.getDescription();
|
||||
|
||||
@@ -331,7 +340,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "crato")
|
||||
public void testRefreshWithoutRequiredPermissions() throws RepositoryException {
|
||||
public void testRefreshWithoutRequiredPermissions() throws AlreadyExistsException, NotFoundException {
|
||||
Repository heartOfGold = RepositoryTestData.createHeartOfGold();
|
||||
manager.create(heartOfGold);
|
||||
heartOfGold.setDescription("prototype ship");
|
||||
@@ -341,12 +350,12 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryNotFoundException.class)
|
||||
public void testRefreshNotFound() throws RepositoryException {
|
||||
public void testRefreshNotFound() throws NotFoundException {
|
||||
manager.refresh(createRepositoryWithId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepositoryHook() throws RepositoryException {
|
||||
public void testRepositoryHook() throws AlreadyExistsException {
|
||||
CountingReceiveHook hook = new CountingReceiveHook();
|
||||
RepositoryManager repoManager = createRepositoryManager(false);
|
||||
|
||||
@@ -375,7 +384,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_withoutLeadingSlash() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_withoutLeadingSlash() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -386,7 +395,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_withLeadingSlash() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_withLeadingSlash() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -397,7 +406,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_withPartialName() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_withPartialName() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -408,7 +417,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_withTrailingFilePath() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_withTrailingFilePath() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -418,7 +427,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_forNotExistingRepositoryName() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_forNotExistingRepositoryName() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -428,7 +437,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryFromRequestUri_forWrongNamespace() throws RepositoryException {
|
||||
public void getRepositoryFromRequestUri_forWrongNamespace() throws AlreadyExistsException {
|
||||
RepositoryManager m = createManager();
|
||||
m.init(contextProvider);
|
||||
|
||||
@@ -438,14 +447,14 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSetNamespace() throws RepositoryException {
|
||||
public void shouldSetNamespace() throws AlreadyExistsException {
|
||||
Repository repository = new Repository(null, "hg", null, "scm");
|
||||
manager.create(repository);
|
||||
assertNotNull(repository.getId());
|
||||
assertNotNull(repository.getNamespace());
|
||||
}
|
||||
|
||||
private void createUriTestRepositories(RepositoryManager m) throws RepositoryException {
|
||||
private void createUriTestRepositories(RepositoryManager m) throws AlreadyExistsException {
|
||||
mockedNamespace = "namespace";
|
||||
createRepository(m, new Repository("1", "hg", "namespace", "scm"));
|
||||
createRepository(m, new Repository("2", "hg", "namespace", "scm-test"));
|
||||
@@ -498,8 +507,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
keyGenerator, repositoryDAO, handlerSet, createRepositoryMatcher(), namespaceStrategy);
|
||||
}
|
||||
|
||||
private void createRepository(RepositoryManager m, Repository repository)
|
||||
throws RepositoryException {
|
||||
private void createRepository(RepositoryManager m, Repository repository) throws AlreadyExistsException {
|
||||
m.create(repository);
|
||||
}
|
||||
|
||||
@@ -526,7 +534,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
return new RepositoryMatcher(Collections.<RepositoryPathMatcher>emptySet());
|
||||
}
|
||||
|
||||
private Repository createRepository(Repository repository) throws RepositoryException {
|
||||
private Repository createRepository(Repository repository) throws AlreadyExistsException {
|
||||
manager.create(repository);
|
||||
assertNotNull(repository.getId());
|
||||
assertNotNull(manager.get(repository.getId()));
|
||||
@@ -541,17 +549,16 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
return repository;
|
||||
}
|
||||
|
||||
private Repository createSecondTestRepository() throws RepositoryException {
|
||||
private Repository createSecondTestRepository() throws AlreadyExistsException {
|
||||
return createRepository(
|
||||
RepositoryTestData.createHappyVerticalPeopleTransporter());
|
||||
}
|
||||
|
||||
private Repository createTestRepository() throws RepositoryException {
|
||||
private Repository createTestRepository() throws AlreadyExistsException {
|
||||
return createRepository(RepositoryTestData.createHeartOfGold());
|
||||
}
|
||||
|
||||
private void delete(Manager<Repository, RepositoryException> manager, Repository repository)
|
||||
throws RepositoryException {
|
||||
private void delete(Manager<Repository> manager, Repository repository) throws NotFoundException {
|
||||
|
||||
String id = repository.getId();
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
*/
|
||||
package sonia.scm.selenium.page;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.List;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.NotFoundException;
|
||||
@@ -41,6 +40,8 @@ import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
import sonia.scm.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Page object for scm-manager's repository creation page.
|
||||
*
|
||||
@@ -130,7 +131,7 @@ public class RepositoriesAddPage extends BasePage<RepositoriesAddPage> {
|
||||
String script = "Sonia.repository.getTypeByName('" + type + "').displayName;";
|
||||
displayName = (String) ((JavascriptExecutor)driver).executeScript(script);
|
||||
}
|
||||
return Objects.firstNonNull(displayName, type);
|
||||
return MoreObjects.firstNonNull(displayName, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user