mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
change NamespaceStrategy signature to createNamespace(Repository)
This change allows us to implement NamespaceStrategies, such as by type (git, hg, svn) or manual defined. The DefaultNamespaceStrategy accepts now a predefined namespace and only if no namespace was set the username of the currently logged in user is used.
This commit is contained in:
@@ -17,8 +17,16 @@ public class DefaultNamespaceStrategyTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "trillian", password = "secret")
|
||||
public void testNamespaceStrategy() {
|
||||
assertEquals("trillian", namespaceStrategy.getNamespace());
|
||||
public void testNamespaceStrategyWithoutPreset() {
|
||||
assertEquals("trillian", namespaceStrategy.createNamespace(new Repository()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "trillian", password = "secret")
|
||||
public void testNamespaceStrategyWithPreset() {
|
||||
Repository repository = new Repository();
|
||||
repository.setNamespace("awesome");
|
||||
assertEquals("awesome", namespaceStrategy.createNamespace(repository));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import sonia.scm.HandlerEventType;
|
||||
import sonia.scm.Manager;
|
||||
@@ -65,9 +66,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -501,7 +500,7 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
||||
configuration.setEnableRepositoryArchive(archiveEnabled);
|
||||
|
||||
NamespaceStrategy namespaceStrategy = mock(NamespaceStrategy.class);
|
||||
when(namespaceStrategy.getNamespace()).thenAnswer(invocation -> mockedNamespace);
|
||||
when(namespaceStrategy.createNamespace(Mockito.any(Repository.class))).thenAnswer(invocation -> mockedNamespace);
|
||||
|
||||
return new DefaultRepositoryManager(configuration, contextProvider,
|
||||
keyGenerator, repositoryDAO, handlerSet, createRepositoryMatcher(), namespaceStrategy);
|
||||
|
||||
Reference in New Issue
Block a user