@@ -0,0 +1,2923 @@
+package it.near.sdk;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0A%0Aimport com.google.common.collect.Maps;%0A%0Aimport org.json.JSONObject;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport it.near.sdk.Recipes.Models.Recipe;%0Aimport it.near.sdk.Recipes.RecipeCooler;%0A%0Aimport static it.near.sdk.Recipes.RecipeCooler.*;%0Aimport static junit.framework.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0A/**%0A * Created by cattaneostefano on 14/02/2017.%0A */%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class RecipeCoolerTest %7B%0A%0A    @Mock%0A    Context mockContext;%0A    @Mock%0A    SharedPreferences mockSharedPreferences;%0A    @Mock%0A    SharedPreferences.Editor mockEditor;%0A%0A    Recipe criticalRecipe;%0A%0A    @Before%0A    public void init() %7B%0A%0A        when(mockContext.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPreferences);%0A        when(mockSharedPreferences.edit()).thenReturn(mockEditor);%0A        when(mockEditor.remove(anyString())).thenReturn(mockEditor);%0A        when(mockEditor.commit()).thenReturn(true);%0A%0A%0A        criticalRecipe = new Recipe();%0A        criticalRecipe.setId(%22recipe_id%22);%0A        HashMap%3CString, Object%3E cooldown = Maps.newHashMap();%0A        cooldown.put(GLOBAL_COOLDOWN, 0L);%0A        cooldown.put(SELF_COOLDOWN, 0L);%0A        criticalRecipe.setCooldown(cooldown);%0A    %7D%0A%0A    @Before%0A    public void resetSingleton() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException %7B%0A        Field instance = RecipeCooler.class.getDeclaredField(%22INSTANCE%22);%0A        instance.setAccessible(true);%0A        instance.set(null, null);%0A    %7D%0A%0A    @Test%0A    public void whenLogIsEmpty_enableRecipe() %7B%0A        when(mockSharedPreferences.getString(eq(LOG_MAP), anyString())).thenReturn(%22%7B%7D%22);%0A%0A        List%3CRecipe%3E recipeList = new ArrayList(Arrays.asList(criticalRecipe));%0A        assertEquals(1, recipeList.size());%0A        RecipeCooler.getInstance(mockContext).filterRecipe(recipeList);%0A        assertEquals(1, recipeList.size());%0A%0A    %7D%0A%0A    @Test%0A    public void whenRecipeShown_historyUpdated() %7B%0A%0A%0A        RecipeCooler.getInstance(mockContext).markRecipeAsShown(%22recipe_id%22);%0A        Map%3CString, Long%3E logMap = Maps.newHashMap();%0A        logMap.put(%22recipe_id%22, System.currentTimeMillis());%0A        JSONObject jsonObject = new JSONObject(logMap);%0A        String jsonString = jsonObject.toString();%0A        verify(mockEditor).putString(eq(LOG_MAP), contains(%22recipe_id%22));%0A%0A    %7D%0A%0A    @Test%0A    public void whenRecipeWithSelfCooldownShown_cantBeShownAgain() %7B%0A        assertTrue(true);%0A        RecipeCooler.getInstance(mockContext).markRecipeAsShown(%22recipe_id%22);%0A    %7D%0A%0A%7D%0A

Add unit test class for recipe cooler.