loadCharactersPerPost(configuration);
loadPostCutOffLength(configuration);
loadRequireFullAccess(configuration);
- loadPositiveTrust(configuration);
- loadNegativeTrust(configuration);
- loadTrustComment(configuration);
loadFcpInterfaceActive(configuration);
loadFcpFullAccessRequired(configuration);
}
.getValue(null));
}
- private void loadPositiveTrust(Configuration configuration) {
- preferences.setNewPositiveTrust(
- configuration.getIntValue("Option/PositiveTrust")
- .getValue(null));
- }
-
- private void loadNegativeTrust(Configuration configuration) {
- preferences.setNewNegativeTrust(
- configuration.getIntValue("Option/NegativeTrust")
- .getValue(null));
- }
-
- private void loadTrustComment(Configuration configuration) {
- preferences.setNewTrustComment(
- configuration.getStringValue("Option/TrustComment")
- .getValue(null));
- }
-
private void loadFcpInterfaceActive(Configuration configuration) {
preferences.setNewFcpInterfaceActive(configuration.getBooleanValue(
"Option/ActivateFcpInterface").getValue(null));
get() = unsupported
set(value) = _requireFullAccess.set(value)
- private val _positiveTrust = DefaultOption(75, range(0, 100))
- val positiveTrust: Int get() = _positiveTrust.get()
- var newPositiveTrust: Int?
- get() = unsupported
- set(value) = _positiveTrust.set(value)
-
- private val _negativeTrust = DefaultOption(-25, range(-100, 100))
- val negativeTrust: Int get() = _negativeTrust.get()
- var newNegativeTrust: Int?
- get() = unsupported
- set(value) = _negativeTrust.set(value)
-
- private val _trustComment = DefaultOption("Set from Sone Web Interface")
- val trustComment: String get() = _trustComment.get()
- var newTrustComment: String?
- get() = unsupported
- set(value) = _trustComment.set(value)
-
private val _fcpInterfaceActive = DefaultOption(false)
val fcpInterfaceActive: Boolean get() = _fcpInterfaceActive.get()
var newFcpInterfaceActive: Boolean?
configuration.getIntValue("Option/CharactersPerPost").value = _charactersPerPost.real
configuration.getIntValue("Option/PostCutOffLength").value = _postCutOffLength.real
configuration.getBooleanValue("Option/RequireFullAccess").value = _requireFullAccess.real
- configuration.getIntValue("Option/PositiveTrust").value = _positiveTrust.real
- configuration.getIntValue("Option/NegativeTrust").value = _negativeTrust.real
- configuration.getStringValue("Option/TrustComment").value = _trustComment.real
configuration.getBooleanValue("Option/ActivateFcpInterface").value = _fcpInterfaceActive.real
configuration.getIntValue("Option/FcpFullAccessRequired").value = toInt(_fcpFullAccessRequired.real)
}
setupIntValue("CharactersPerPost", 150);
setupIntValue("PostCutOffLength", 300);
setupBooleanValue("RequireFullAccess", true);
- setupIntValue("PositiveTrust", 50);
- setupIntValue("NegativeTrust", -50);
- when(configuration.getStringValue("Option/TrustComment")).thenReturn(
- TestValue.from("Trusted"));
setupBooleanValue("ActivateFcpInterface", true);
setupIntValue("FcpFullAccessRequired", 1);
}
assertThat(preferences.getCharactersPerPost(), is(150));
assertThat(preferences.getPostCutOffLength(), is(300));
assertThat(preferences.getRequireFullAccess(), is(true));
- assertThat(preferences.getPositiveTrust(), is(50));
- assertThat(preferences.getNegativeTrust(), is(-50));
- assertThat(preferences.getTrustComment(), is("Trusted"));
assertThat(preferences.getFcpInterfaceActive(), is(true));
assertThat(preferences.getFcpFullAccessRequired(), is(WRITING));
}
}
@Test
- fun `preferences retain positive trust`() {
- preferences.newPositiveTrust = 15
- assertThat(preferences.positiveTrust, equalTo(15))
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun `invalid positive trust is rejected`() {
- preferences.newPositiveTrust = -15
- }
-
- @Test
- fun `preferences return default value when positive trust is set to null`() {
- preferences.newPositiveTrust = null
- assertThat(preferences.positiveTrust, equalTo(75))
- }
-
- @Test
- fun `preferences start with positive trust default value`() {
- assertThat(preferences.positiveTrust, equalTo(75))
- }
-
- @Test
- fun `preferences retain negative trust`() {
- preferences.newNegativeTrust = -15
- assertThat(preferences.negativeTrust, equalTo(-15))
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun `invalid negative trust is rejected`() {
- preferences.newNegativeTrust = 150
- }
-
- @Test
- fun `preferences return default value when negative trust is set to null`() {
- preferences.newNegativeTrust = null
- assertThat(preferences.negativeTrust, equalTo(-25))
- }
-
- @Test
- fun `preferences start with negative trust default value`() {
- assertThat(preferences.negativeTrust, equalTo(-25))
- }
-
- @Test
- fun `preferences retain trust comment`() {
- preferences.newTrustComment = "Trust"
- assertThat(preferences.trustComment, equalTo("Trust"))
- }
-
- @Test
- fun `preferences return default value when trust comment is set to null`() {
- preferences.newTrustComment = null
- assertThat(preferences.trustComment,
- equalTo("Set from Sone Web Interface"))
- }
-
- @Test
- fun `preferences start with trust comment default value`() {
- assertThat(preferences.trustComment,
- equalTo("Set from Sone Web Interface"))
- }
-
- @Test
fun `preferences retain fcp interface active of true`() {
preferences.newFcpInterfaceActive = true
assertThat(preferences.fcpInterfaceActive, equalTo(true))