X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdatabase%2Fmemory%2FMemoryDatabaseTest.java;h=9d704a644171a93b6026814295626e40a736771a;hb=77200211a06c3c40ae08db27487ef8426d2f26c6;hp=31532e284d4e6a07875c90f832fb59e775d99ee2;hpb=cbd6de75a2a96966a2381100c5b643feea702458;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index 31532e2..9d704a6 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -215,7 +215,7 @@ public class MemoryDatabaseTest { @Test public void storedAndRemovedSoneIsNotAvailable() { - storedSoneIsMadeAvailable(); + storedSoneIsMadeAvailable(); memoryDatabase.removeSone(sone); assertThat(memoryDatabase.getSones(), empty()); } @@ -429,4 +429,32 @@ public class MemoryDatabaseTest { assertThat(configuration.getStringValue("SoneFollowingTimes/1/Sone").getValue(), nullValue()); } + @Test + public void unfollowingASoneRemovesTheFollowingTime() throws ConfigurationException { + prepareConfigurationValues(); + configuration.getStringValue("Sone/sone/Friends/0/ID").setValue("Friend"); + configuration.getStringValue("SoneFollowingTimes/0/Sone").setValue("Friend"); + configuration.getLongValue("SoneFollowingTimes/0/Time").setValue(1000L); + when(sone.isLocal()).thenReturn(true); + memoryDatabase.removeFriend(sone, "Friend"); + assertThat(configuration.getStringValue("SoneFollowingTimes/0/Sone").getValue(), nullValue()); + } + + @Test + public void unfollowingASoneDoesNotRemoveTheFollowingTimeIfAnotherLocalSoneFollowsIt() throws ConfigurationException { + prepareConfigurationValues(); + configuration.getStringValue("Sone/sone/Friends/0/ID").setValue("Friend"); + configuration.getStringValue("Sone/other-sone/Friends/0/ID").setValue("Friend"); + configuration.getStringValue("SoneFollowingTimes/0/Sone").setValue("Friend"); + configuration.getLongValue("SoneFollowingTimes/0/Time").setValue(1000L); + Sone otherSone = mock(Sone.class); + when(otherSone.isLocal()).thenReturn(true); + when(otherSone.getId()).thenReturn("other-sone"); + memoryDatabase.getFriends(otherSone); + when(sone.isLocal()).thenReturn(true); + memoryDatabase.removeFriend(sone, "Friend"); + assertThat(configuration.getStringValue("SoneFollowingTimes/0/Sone").getValue(), equalTo("Friend")); + assertThat(configuration.getLongValue("SoneFollowingTimes/0/Time").getValue(), equalTo(1000L)); + } + }