From: David ‘Bombe’ Roden Date: Tue, 30 Sep 2014 05:11:58 +0000 (+0200) Subject: Move test Value implementation to top-level class. X-Git-Tag: 0.9-rc1^2~3^2~85 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=dfc936c18f048843bd0c47553713e752e9824658;p=Sone.git Move test Value implementation to top-level class. --- diff --git a/src/test/java/net/pterodactylus/sone/TestValue.java b/src/test/java/net/pterodactylus/sone/TestValue.java new file mode 100644 index 0000000..4f3058b --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/TestValue.java @@ -0,0 +1,37 @@ +package net.pterodactylus.sone; + +import java.util.concurrent.atomic.AtomicReference; + +import net.pterodactylus.util.config.ConfigurationException; +import net.pterodactylus.util.config.Value; + +/** +* Simple {@link Value} implementation. +* +* @author David ‘Bombe’ Roden +*/ +public class TestValue implements Value { + + private final AtomicReference value = new AtomicReference(); + + public TestValue(T originalValue) { + value.set(originalValue); + } + + @Override + public T getValue() throws ConfigurationException { + return value.get(); + } + + @Override + public T getValue(T defaultValue) { + final T realValue = value.get(); + return (realValue != null) ? realValue : defaultValue; + } + + @Override + public void setValue(T newValue) throws ConfigurationException { + value.set(newValue); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java index c8742c2..e30048b 100644 --- a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java @@ -22,12 +22,12 @@ import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; import net.pterodactylus.sone.TestAlbumBuilder; import net.pterodactylus.sone.TestImageBuilder; import net.pterodactylus.sone.TestPostBuilder; import net.pterodactylus.sone.TestPostReplyBuilder; +import net.pterodactylus.sone.TestValue; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidAlbumFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidImageFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidParentAlbumFound; @@ -48,8 +48,6 @@ import net.pterodactylus.sone.database.PostBuilderFactory; import net.pterodactylus.sone.database.PostReplyBuilder; import net.pterodactylus.sone.database.PostReplyBuilderFactory; import net.pterodactylus.util.config.Configuration; -import net.pterodactylus.util.config.ConfigurationException; -import net.pterodactylus.util.config.Value; import com.google.common.base.Optional; import org.hamcrest.Matchers; @@ -523,30 +521,4 @@ public class ConfigurationSoneParserTest { configurationSoneParser.parseImages(createImageBuilderFactory()); } - private static class TestValue implements Value { - - private final AtomicReference value = new AtomicReference(); - - public TestValue(T originalValue) { - value.set(originalValue); - } - - @Override - public T getValue() throws ConfigurationException { - return value.get(); - } - - @Override - public T getValue(T defaultValue) { - final T realValue = value.get(); - return (realValue != null) ? realValue : defaultValue; - } - - @Override - public void setValue(T newValue) throws ConfigurationException { - value.set(newValue); - } - - } - }