import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
}
}
+ @Nullable
+ Long getFollowingTime(@Nonnull String soneId) {
+ return configurationLoader.getSoneFollowingTime(soneId);
+ }
+
private void loadFriends(String localSoneId) {
lock.writeLock().lock();
try {
}
@Test
+ public void soneFollowingTimeIsReturnedCorrectly() throws ConfigurationException {
+ prepareConfigurationValues();
+ configuration.getStringValue("SoneFollowingTimes/0/Sone").setValue("sone");
+ configuration.getLongValue("SoneFollowingTimes/0/Time").setValue(1000L);
+ assertThat(memoryDatabase.getFollowingTime("sone"), equalTo(1000L));
+ }
+
+ @Test
+ public void nullisReturnedWhenSoneIsNotFollowed() throws ConfigurationException {
+ prepareConfigurationValues();
+ configuration.getStringValue("SoneFollowingTimes/0/Sone").setValue("otherSone");
+ configuration.getLongValue("SoneFollowingTimes/0/Time").setValue(1000L);
+ assertThat(memoryDatabase.getFollowingTime("sone"), nullValue());
+ }
+
+ @Test
public void timeIsStoredInConfigurationWhenASoneIsFollowed() throws ConfigurationException {
prepareConfigurationValues();
when(sone.isLocal()).thenReturn(true);