package umm3601.plant;

import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import umm3601.digitalDisplayGarden.Plant;
import umm3601.digitalDisplayGarden.PlantController;
import umm3601.plant.PopulateMockDatabase;

import java.io.IOException;

import static junit.framework.TestCase.assertEquals;

public class FilterByUniqueGardenLocations {
    @Before
    public void setUpDB() throws IOException{
        PopulateMockDatabase mockDatabase = new PopulateMockDatabase();
        mockDatabase.clearAndPopulateDBAgain();
    }

    @Test
    public void findByGardenLocation() throws IOException {
        PlantController plantController = new PlantController();
        GardenLocation[] filteredPlants;
        Gson gson = new Gson();
        //System.out.println();
        String rawPlants = plantController.getPlantsByGardenLocations("first uploadId");
        filteredPlants = gson.fromJson(rawPlants, GardenLocation[].class);
        assertEquals("Incorrect number of unique garden locations", 2, filteredPlants.length);
        assertEquals("Incorrect zero index", "10.0", filteredPlants[0]._id);
        assertEquals("Incorrect value for index 1", "7.0", filteredPlants[1]._id);
    }
}

@@ -1023,9 +1023,9 @@
 s%22, 
-2
+1
 , fi
@@ -1175,14 +1175,15 @@
 dex 
-1
+0
 %22, %22
-7
+10
 .0%22,
@@ -1198,17 +1198,17 @@
 dPlants%5B
-1
+0
 %5D._id);%0A

Fix test for FilterByUniqueGardenLocations to work with the new mock data