X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FPreferencesLoaderTest.java;h=72831fc15585ae68c2b8ff88033288c340aa82ad;hb=c9ffc9e14a08744966c0f0ae7d2acb92bbb04139;hp=91120fb0ed7a26714df45e88cfbb54870e9776db;hpb=c5fff3247c8a680f816db28df64d6439779f5c82;p=Sone.git
diff --git a/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java b/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java
index 91120fb..72831fc 100644
--- a/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java
+++ b/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java
@@ -3,10 +3,11 @@ package net.pterodactylus.sone.core;
import static net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import net.pterodactylus.sone.TestValue;
+import net.pterodactylus.sone.test.TestValue;
import net.pterodactylus.util.config.Configuration;
import com.google.common.eventbus.EventBus;
@@ -15,8 +16,6 @@ import org.junit.Test;
/**
* Unit test for {@link PreferencesLoader}.
- *
- * @author David âBombeâ Roden
*/
public class PreferencesLoaderTest {
@@ -34,23 +33,19 @@ public class PreferencesLoaderTest {
setupIntValue("CharactersPerPost", 150);
setupIntValue("PostCutOffLength", 300);
setupBooleanValue("RequireFullAccess", true);
- setupIntValue("PositiveTrust", 50);
- setupIntValue("NegativeTrust", -50);
- when(configuration.getStringValue("Option/TrustComment")).thenReturn(
- new TestValue("Trusted"));
setupBooleanValue("ActivateFcpInterface", true);
setupIntValue("FcpFullAccessRequired", 1);
}
private void setupIntValue(String optionName, int value) {
when(configuration.getIntValue("Option/" + optionName)).thenReturn(
- new TestValue(value));
+ TestValue.from(value));
}
private void setupBooleanValue(String optionName, boolean value) {
when(configuration.getBooleanValue(
"Option/" + optionName)).thenReturn(
- new TestValue(value));
+ TestValue.from(value));
}
@Test
@@ -62,12 +57,17 @@ public class PreferencesLoaderTest {
assertThat(preferences.getImagesPerPage(), is(12));
assertThat(preferences.getCharactersPerPost(), is(150));
assertThat(preferences.getPostCutOffLength(), is(300));
- assertThat(preferences.isRequireFullAccess(), is(true));
- assertThat(preferences.getPositiveTrust(), is(50));
- assertThat(preferences.getNegativeTrust(), is(-50));
- assertThat(preferences.getTrustComment(), is("Trusted"));
- assertThat(preferences.isFcpInterfaceActive(), is(true));
+ assertThat(preferences.getRequireFullAccess(), is(true));
+ assertThat(preferences.getFcpInterfaceActive(), is(true));
assertThat(preferences.getFcpFullAccessRequired(), is(WRITING));
}
+ @Test
+ public void configurationIsLoadedCorrectlyWithCutOffLengthMinusOne() {
+ setupConfiguration();
+ setupIntValue("PostCutOffLength", -1);
+ preferencesLoader.loadFrom(configuration);
+ assertThat(preferences.getPostCutOffLength(), not(is(-1)));
+ }
+
}