Next up: extract an interface, use that everywhere.
private final AtomicBoolean debug = new AtomicBoolean(false);
/** The preferences. */
- private final Preferences preferences;
+ private final DefaultPreferences preferences;
/** The event bus. */
private final EventBus eventBus;
this.database = database;
this.metricRegistry = metricRegistry;
this.soneUriCreator = soneUriCreator;
- preferences = new Preferences(eventBus);
+ preferences = new DefaultPreferences(eventBus);
this.configurationSaveTimeHistogram = metricRegistry.histogram("configuration.save.duration", () -> new Histogram(new ExponentiallyDecayingReservoir(3000, 0)));
}
*
* @return The options of the core
*/
- public Preferences getPreferences() {
+ public DefaultPreferences getPreferences() {
return preferences;
}
* Convenience interface for external classes that want to access the core’s
* configuration.
*/
-class Preferences(private val eventBus: EventBus) {
+class DefaultPreferences(private val eventBus: EventBus) {
private val _insertionDelay = DefaultOption(60) { it in 0..MAX_VALUE }
val insertionDelay: Int get() = _insertionDelay.get()
import net.pterodactylus.util.config.*
/**
- * Loads preferences stored in a [Configuration] into a [Preferences] object.
+ * Loads preferences stored in a [Configuration] into a [DefaultPreferences] object.
*/
-class PreferencesLoader(private val preferences: Preferences) {
+class PreferencesLoader(private val preferences: DefaultPreferences) {
fun loadFrom(configuration: Configuration) {
loadInsertionDelay(configuration)
package net.pterodactylus.sone.core.event
/**
- * Event that signals that the “[strict filtering][net.pterodactylus.sone.core.Preferences.strictFiltering]”
+ * Event that signals that the “[strict filtering][net.pterodactylus.sone.core.DefaultPreferences.strictFiltering]”
* preference was activated.
*/
class StrictFilteringActivatedEvent
/**
- * Event that signals that the “[strict filtering][net.pterodactylus.sone.core.Preferences.strictFiltering]”
+ * Event that signals that the “[strict filtering][net.pterodactylus.sone.core.DefaultPreferences.strictFiltering]”
* preference was deactivated.
*/
class StrictFilteringDeactivatedEvent
@Suppress("UnstableApiUsage")
private val eventBus = EventBus()
- private val preferences = Preferences(eventBus)
+ private val preferences = DefaultPreferences(eventBus)
private val configuration = Configuration(MapConfigurationBackend())
private val preferencesLoader = PreferencesLoader(preferences)
import org.junit.Test
/**
- * Unit test for [Preferences].
+ * Unit test for [DefaultPreferences].
*/
-class PreferencesTest {
+class DefaultPreferencesTest {
private val eventBus = EventBus()
- private val preferences = Preferences(eventBus)
+ private val preferences = DefaultPreferences(eventBus)
@Test
fun `preferences retain insertion delay`() {
package net.pterodactylus.sone.web.ajax
-import net.pterodactylus.sone.core.Preferences
+import net.pterodactylus.sone.core.DefaultPreferences
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.web.Response
@Before
fun setupCore() {
- whenever(core.preferences).thenReturn(Preferences(eventBus))
+ whenever(core.preferences).thenReturn(DefaultPreferences(eventBus))
}
@Before
import net.pterodactylus.sone.core.Core
import net.pterodactylus.sone.core.ElementLoader
import net.pterodactylus.sone.core.LinkedElement
-import net.pterodactylus.sone.core.Preferences
+import net.pterodactylus.sone.core.DefaultPreferences
import net.pterodactylus.sone.core.UpdateChecker
import net.pterodactylus.sone.data.Album
import net.pterodactylus.sone.data.Image
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.notify.Notification
-import net.pterodactylus.util.template.TemplateContextFactory
import net.pterodactylus.util.web.Method.GET
import net.pterodactylus.util.web.Method.POST
import org.mockito.ArgumentMatchers
var formPassword = "form-password"
val core = mock<Core>()
val eventBus = mock<EventBus>()
- val preferences = Preferences(eventBus)
+ val preferences = DefaultPreferences(eventBus)
val updateChecker = mock<UpdateChecker>()
val elementLoader = mock<ElementLoader>()
val newElements = mock<NewElements>()
val webInterface = deepMock<WebInterface>()
val core = webInterface.core
val eventBus = mock<EventBus>()
- val preferences = Preferences(eventBus)
+ val preferences = DefaultPreferences(eventBus)
open val page by lazy { pageSupplier(webInterface, loaders, templateRenderer) }