@@ -0,0 +1,2230 @@
+package api.v1.Tests;%0A%0Aimport api.v1.Utils.JSONRecipeValidator;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport api.v1.Controllers.*;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0A%0Aimport static org.junit.Assert.*;%0Aimport java.util.List;%0A%0Aimport  net.minidev.json.JSONObject;%0A%0A/**%0A * Created by Vlad Stefan on 5/14/2017.%0A */%0Apublic class RecipesControllerTest %7B%0A%0A    @Test%0A    public void index() throws Exception %7B%0A%0A        succesRequestIndex();%0A        failRequestIndex();%0A%0A    %7D%0A%0A    @Test%0A    public void show() throws Exception %7B%0A    %7D%0A%0A    @Test%0A    public void preview() throws Exception %7B%0A    %7D%0A%0A    @Test%0A    public void search() throws Exception %7B%0A    %7D%0A%0A%0A    /**%0A     * Tests index method of RecipesController class%0A     * with a valid parameter.%0A     * It tests the respond's status and the format%0A     * of recipes list%0A     */%0A    private void succesRequestIndex() %7B%0A%0A        RecipesController recipesControllerTest = new RecipesController();%0A%0A        ResponseEntity result = recipesControllerTest.index(1);%0A%0A        assertEquals(result.getStatusCode(), HttpStatus.OK);%0A%0A        assertEquals(true,result.hasBody());%0A%0A        if(!result.hasBody())%0A            System.out.println(%22Body%22);%0A%0A        JSONObject body = (JSONObject) result.getBody();%0A%0A        assertEquals(true,body.containsKey(%22recipes%22));%0A%0A        List%3CJSONObject%3E recipesList = null;%0A%0A        JSONRecipeValidator recipeValidator = new JSONRecipeValidator();%0A%0A        try %7B%0A            for (JSONObject recipe : recipesList = (List%3CJSONObject%3E) body.get(%22recipes%22)) %7B%0A%0A                assertEquals(true,recipeValidator.isValid(recipe));%0A            %7D%0A        %7D%0A        catch (Exception e) %7B%0A%0A            System.out.println(%22couldn't iterate through recipes in index method%22);%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * Tests index method of RecipesController class%0A     * with an invalid parameter%0A     */%0A    private void failRequestIndex() %7B%0A%0A        RecipesController recipesControllerTest = new RecipesController();%0A%0A        ResponseEntity resultNegativeInt = recipesControllerTest.index(-1);%0A        assertEquals(resultNegativeInt.getStatusCode(), HttpStatus.BAD_REQUEST);%0A%0A    %7D%0A%7D

add index test