/*
- * Sone - MemoryDatabaseTest.java - Copyright © 2013 David Roden
+ * Sone - MemoryDatabaseTest.java - Copyright © 2013–2015 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
private void initializeFriends() {
when(configuration.getStringValue("Sone/" + SONE_ID + "/Friends/0/ID")).thenReturn(
- new TestValue<String>("Friend1"));
+ TestValue.from("Friend1"));
when(configuration.getStringValue("Sone/" + SONE_ID + "/Friends/1/ID")).thenReturn(
- new TestValue<String>("Friend2"));
+ TestValue.from("Friend2"));
when(configuration.getStringValue("Sone/" + SONE_ID + "/Friends/2/ID")).thenReturn(
- new TestValue<String>(null));
+ TestValue.<String>from(null));
}
@Test
when(configuration.getStringValue(anyString())).thenAnswer(new Answer<Value<String>>() {
@Override
public Value<String> answer(InvocationOnMock invocation) throws Throwable {
- Value<String> stringValue = new TestValue(null);
+ Value<String> stringValue = TestValue.from(null);
configurationValues.put((String) invocation.getArguments()[0], stringValue);
return stringValue;
}
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());
}
}