}
void addFriend(String localSoneId, String friendSoneId) {
+ loadFriends(localSoneId);
lock.writeLock().lock();
try {
if (soneFriends.put(localSoneId, friendSoneId)) {
}
void removeFriend(String localSoneId, String friendSoneId) {
+ loadFriends(localSoneId);
lock.writeLock().lock();
try {
if (soneFriends.remove(localSoneId, friendSoneId)) {
when(sone.isLocal()).thenReturn(true);
memoryDatabase.addFriend(sone, "Friend1");
memoryDatabase.addFriend(sone, "Friend1");
- verify(configuration, times(2)).getStringValue(anyString());
+ verify(configuration, times(3)).getStringValue(anyString());
}
@Test
@Test
public void configurationIsNotWrittenWhenANonFriendIsRemoved() {
+ prepareConfigurationValues();
when(sone.isLocal()).thenReturn(true);
memoryDatabase.removeFriend(sone, "Friend1");
- verify(configuration, never()).getStringValue(anyString());
+ verify(configuration).getStringValue(anyString());
}
}