X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FConfigurationSoneParserTest.java;h=7deb8058db4d93fa4f4647f65e103244772f2e9d;hp=c8742c24f42065756c75b8b928e2f625b5cbf461;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=527ba49512006908c5bae602e34a1ce7167ea3fe diff --git a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java index c8742c2..7deb805 100644 --- a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java @@ -13,8 +13,8 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -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; @@ -90,9 +88,9 @@ public class ConfigurationSoneParserTest { private void setupEmptyProfile() { when(configuration.getStringValue(anyString())).thenReturn( - new TestValue(null)); + TestValue.from(null)); when(configuration.getIntValue(anyString())).thenReturn( - new TestValue(null)); + TestValue.from(null)); } @Test @@ -130,12 +128,12 @@ public class ConfigurationSoneParserTest { private void setupString(String nodeName, String value) { when(configuration.getStringValue(eq(nodeName))).thenReturn( - new TestValue(value)); + TestValue.from(value)); } private void setupInteger(String nodeName, Integer value) { when(configuration.getIntValue(eq(nodeName))).thenReturn( - new TestValue(value)); + TestValue.from(value)); } @Test @@ -182,7 +180,7 @@ public class ConfigurationSoneParserTest { private void setupLong(String nodeName, Long value) { when(configuration.getLongValue(eq(nodeName))).thenReturn( - new TestValue(value)); + TestValue.from(value)); } @Test(expected = InvalidPostFound.class) @@ -335,15 +333,15 @@ public class ConfigurationSoneParserTest { albumBuilderFactory); assertThat(topLevelAlbums, hasSize(2)); Album firstAlbum = topLevelAlbums.get(0); - assertThat(firstAlbum, isAlbum("A1", null, "T1", "D1", "I1")); + assertThat(firstAlbum, isAlbum("A1", null, "T1", "D1")); assertThat(firstAlbum.getAlbums(), emptyIterable()); assertThat(firstAlbum.getImages(), emptyIterable()); Album secondAlbum = topLevelAlbums.get(1); - assertThat(secondAlbum, isAlbum("A2", null, "T2", "D2", null)); + assertThat(secondAlbum, isAlbum("A2", null, "T2", "D2")); assertThat(secondAlbum.getAlbums(), hasSize(1)); assertThat(secondAlbum.getImages(), emptyIterable()); Album thirdAlbum = secondAlbum.getAlbums().get(0); - assertThat(thirdAlbum, isAlbum("A3", "A2", "T3", "D3", "I3")); + assertThat(thirdAlbum, isAlbum("A3", "A2", "T3", "D3")); assertThat(thirdAlbum.getAlbums(), emptyIterable()); assertThat(thirdAlbum.getImages(), emptyIterable()); } @@ -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); - } - - } - }