private static Map<String, Object> stored = new HashMap<String, Object>();
private static Map<String, Object> serialized = new HashMap<String, Object>();
// @formatter:on
public static LocalStorage createMockStorage() {
LocalStorage storage = mock(LocalStorage.class);
when(storage.isPresent()).thenReturn(true);
// @formatter:off
when(storage.getStringValue(anyString())).thenAnswer(new Answer<String>() {
public String answer(InvocationOnMock inv) {
String value = (String) getValue(inv);
return (value != null)? value : "";
}
});
when(storage.getLongValue(anyString())).thenAnswer(new Answer<Long>() {
public Long answer(InvocationOnMock inv) {
Long value = (Long) getValue(inv);
return (value != null)? value : 0L;
}
});
when(storage.getBooleanValue(anyString())).thenAnswer(new Answer<Boolean>() {
public Boolean answer(InvocationOnMock inv) {
Boolean value = (Boolean) getValue(inv);
return (value != null)? value : false;
}
});