From dfc936c18f048843bd0c47553713e752e9824658 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 30 Sep 2014 07:11:58 +0200 Subject: [PATCH] Move test Value implementation to top-level class. --- .../java/net/pterodactylus/sone/TestValue.java | 37 ++++++++++++++++++++++ .../sone/core/ConfigurationSoneParserTest.java | 30 +----------------- 2 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 src/test/java/net/pterodactylus/sone/TestValue.java 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); - } - - } - } -- 2.7.4