mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
add the interface StoreFactory and refactor storeFactories
This commit is contained in:
@@ -66,7 +66,7 @@ public class AutoCompleteResourceTest {
|
||||
ConfigurationStore<Object> storeConfig = mock(ConfigurationStore.class);
|
||||
xmlDB = mock(XmlDatabase.class);
|
||||
when(storeConfig.get()).thenReturn(xmlDB);
|
||||
when(storeFactory.getStore(any(), any())).thenReturn(storeConfig);
|
||||
when(storeFactory.getStore(any())).thenReturn(storeConfig);
|
||||
XmlUserDAO userDao = new XmlUserDAO(storeFactory);
|
||||
this.userDao = spy(userDao);
|
||||
XmlGroupDAO groupDAO = new XmlGroupDAO(storeFactory);
|
||||
|
||||
@@ -422,10 +422,10 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository> {
|
||||
private DefaultRepositoryManager createRepositoryManager(boolean archiveEnabled, KeyGenerator keyGenerator) {
|
||||
DefaultFileSystem fileSystem = new DefaultFileSystem();
|
||||
Set<RepositoryHandler> handlerSet = new HashSet<>();
|
||||
ConfigurationStoreFactory factory = new JAXBConfigurationStoreFactory(contextProvider);
|
||||
InitialRepositoryLocationResolver initialRepositoryLocationResolver = new InitialRepositoryLocationResolver(contextProvider, fileSystem);
|
||||
XmlRepositoryDAO repositoryDAO = new XmlRepositoryDAO(factory, initialRepositoryLocationResolver);
|
||||
XmlRepositoryDAO repositoryDAO = new XmlRepositoryDAO(initialRepositoryLocationResolver, contextProvider);
|
||||
RepositoryLocationResolver repositoryLocationResolver = new RepositoryLocationResolver(repositoryDAO, initialRepositoryLocationResolver);
|
||||
ConfigurationStoreFactory factory = new JAXBConfigurationStoreFactory(repositoryLocationResolver);
|
||||
handlerSet.add(new DummyRepositoryHandler(factory, repositoryLocationResolver));
|
||||
handlerSet.add(new DummyRepositoryHandler(factory, repositoryLocationResolver) {
|
||||
@Override
|
||||
|
||||
@@ -36,20 +36,21 @@ package sonia.scm.security;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import io.jsonwebtoken.Jwts;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import sonia.scm.store.ConfigurationEntryStore;
|
||||
import sonia.scm.store.ConfigurationEntryStoreFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.argThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -122,11 +123,13 @@ public class SecureKeyResolverTest
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
ConfigurationEntryStoreFactory factory =
|
||||
mock(ConfigurationEntryStoreFactory.class);
|
||||
ConfigurationEntryStoreFactory factory = mock(ConfigurationEntryStoreFactory.class);
|
||||
|
||||
when(factory.getStore(SecureKey.class,
|
||||
SecureKeyResolver.STORE_NAME)).thenReturn(store);
|
||||
when(factory.getStore(argThat(storeParameters -> {
|
||||
assertThat(storeParameters.getName()).isEqualTo(SecureKeyResolver.STORE_NAME);
|
||||
assertThat(storeParameters.getType()).isEqualTo(SecureKey.class);
|
||||
return true;
|
||||
}))).thenReturn(store);
|
||||
resolver = new SecureKeyResolver(factory);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,6 @@ public class DefaultUserManagerTest extends UserManagerTestBase
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
private XmlUserDAO createXmlUserDAO() {
|
||||
return new XmlUserDAO(new JAXBConfigurationStoreFactory(contextProvider));
|
||||
return new XmlUserDAO(new JAXBConfigurationStoreFactory(locationResolver));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user