add the interface StoreFactory and refactor storeFactories

This commit is contained in:
Mohamed Karray
2018-11-27 11:35:02 +01:00
parent 39e5c19251
commit 7a1de0f67b
42 changed files with 485 additions and 291 deletions

View File

@@ -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);
}