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 FilterPlantsByGardenLocation {
    @Before
    public void setUpDB() throws IOException{
        PopulateMockDatabase mockDatabase = new PopulateMockDatabase();
        mockDatabase.clearAndPopulateDBAgain();
    }

    @Test
    public void findByGardenLocation() throws IOException {
        PlantController plantController = new PlantController();
        Plant[] filteredPlants;
        Gson gson = new Gson();

        String rawPlants = plantController.getGardenLocations();
        filteredPlants = gson.fromJson(rawPlants, Plant[].class);
        assertEquals("Incorrect", 1, filteredPlants.length);
    }
}

@@ -689,21 +689,30 @@
         
-Plant
+GardenLocation
 %5B%5D filte
@@ -754,16 +754,47 @@
 Gson();%0A
+        //System.out.println();
 %0A       
@@ -901,21 +901,30 @@
 Plants, 
-Plant
+GardenLocation
 %5B%5D.class
@@ -961,12 +961,46 @@
 rect
+ number of unique garden locations
 %22, 
-1
+2
 , fi
@@ -1021,16 +1021,176 @@
 ength);%0A
+        assertEquals(%22Incorrect zero index%22, %2210.0%22, filteredPlants%5B0%5D._id);%0A        assertEquals(%22Incorrect value for index 1%22, %227.0%22, filteredPlants%5B1%5D._id);%0A
     %7D%0A%7D%0A

Add and pass tests for gardenLocation