@Test
  public void testGetAutoPlantingDate_machakos() throws IOException, Exception {
    URL test_resource = this.getClass().getResource("/machakos_wth_only.json");
    String line;
    String startDate = "01-15";
    String endDate = "02-28";
    String accRainAmt = "9.0";
    String dayNum = "6";
    String expected_1 = "19800124";
    String expected_2 = "19810218";
    int expected_3 = 3;
    String acctual_1 = "";
    String acctual_2 = "";
    int acctual_3 = 0;

    BufferedReader br =
        new BufferedReader(new InputStreamReader(new FileInputStream(test_resource.getPath())));

    if ((line = br.readLine()) != null) {

      HashMap<String, Object> data = JSONAdapter.fromJSON(line);
      data.put("exp_dur", "3");
      HashMap<String, ArrayList<String>> results =
          ExperimentHelper.getAutoPlantingDate(data, startDate, endDate, accRainAmt, dayNum);
      acctual_1 = results.get("pdate").get(0);
      acctual_2 = results.get("pdate").get(1);
      acctual_3 = results.get("pdate").size();
      log.info("Results: {}", results);
    }

    assertEquals("getAutoPlantingDate: normal case", expected_1, acctual_1);
    assertEquals("getAutoPlantingDate: copy case", expected_2, acctual_2);
    assertEquals("getAutoPlantingDate: no date find case", expected_3, acctual_3);
  }
  @Test
  @Ignore
  public void testGetAutoPlantingDate_oneYear() throws IOException, Exception {
    String line;
    String startDate = "03-01";
    String endDate = "04-01";
    String accRainAmt = "9.0";
    String dayNum = "6";
    String expected_1 = "19990310"; // TODO
    int expected_2 = 3;
    String acctual_1 = "";
    int acctual_2 = 0;
    URL test_resource = null;
    BufferedReader br =
        new BufferedReader(new InputStreamReader(new FileInputStream(test_resource.getPath())));

    if ((line = br.readLine()) != null) {

      HashMap<String, ArrayList<Map>> data = new LinkedHashMap<String, ArrayList<Map>>();
      Map<String, Object> expData = JSONAdapter.fromJSON(line);
      data.put("experiments", new ArrayList());
      data.put("weathers", new ArrayList());
      data.get("experiments").add(expData);
      data.get("weathers").add((Map) expData.get("weather"));
      expData.put("sc_year", "1982");
      ExperimentHelper.getAutoPlantingDate(data, startDate, endDate, accRainAmt, dayNum);
      Map<String, ArrayList> mgnData = (Map) expData.get("management");
      ArrayList<Map<String, String>> events = mgnData.get("events");
      acctual_1 = events.get(0).get("date");
      acctual_2 = events.size();
    }

    assertEquals("getAutoPlantingDate: normal case", expected_1, acctual_1);
    assertEquals("getAutoPlantingDate: no date find case", expected_2, acctual_2);
  }
  @Test
  public void testGetAutoPlantingDate() throws IOException, Exception {
    String line;
    String startDate = "01-15";
    String endDate = "02-28";
    String accRainAmt = "25";
    String dayNum = "4";
    String expected_1 = "19820203";
    int expected_2 = 2; // 5 standard events + 1 new planting event
    String acctual_1 = "";
    int acctual_2 = 0;
    URL test_resource = this.getClass().getResource("/auto_plant_single_year_test.json");
    ArrayList<Map<String, String>> events = new ArrayList<Map<String, String>>();
    HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
    BufferedReader br =
        new BufferedReader(new InputStreamReader(new FileInputStream(test_resource.getPath())));

    if ((line = br.readLine()) != null) {
      HashMap<String, Object> data = JSONAdapter.fromJSON(line);
      // Map<String, Object> expData = getRawPackageContents(data, "experiments").get(0);
      // Map<String, Object> expData = (Map)((ArrayList) data.get("experiments")).get(0);
      data.put("exp_dur", "2");
      results = ExperimentHelper.getAutoPlantingDate(data, startDate, endDate, accRainAmt, dayNum);
      // Map<String, ArrayList> mgnData = (Map) data.get("results");
      // events = mgnData.get("events");
      // acctual_1 = results.get(0);
    }
    log.info("Results: {}", results);

    assertEquals("getAutoPlantingDate: normal case", expected_1, results.get("pdate").get(0));
    assertEquals("getAutoPlantingDate: no date find case", expected_2, results.get("pdate").size());
  }
  @Test
  @Ignore
  public void testGetAutoPlantingDate_machakos_scYear() throws IOException, Exception {
    String line;
    String startDate = "01-15";
    String endDate = "02-28";
    String accRainAmt = "9.0";
    String dayNum = "6";
    String expected_1 = "19830214";
    String expected_2 = "19840131";
    String expected_3 = "19850202";
    int expected_99 = 3;
    String acctual_1 = "";
    String acctual_2 = "";
    String acctual_3 = "";
    int acctual_99 = 0;

    URL test_resource = this.getClass().getResource("/machakos_wth_only.json");
    BufferedReader br =
        new BufferedReader(new InputStreamReader(new FileInputStream(test_resource.getPath())));

    if ((line = br.readLine()) != null) {

      HashMap<String, Object> data = JSONAdapter.fromJSON(line);
      data.put("exp_dur", "3");
      data.put("sc_year", "1983");
      HashMap<String, ArrayList<String>> result =
          ExperimentHelper.getAutoPlantingDate(data, startDate, endDate, accRainAmt, dayNum);
      Map<String, ArrayList> mgnData = (Map) data.get("management");
      ArrayList<Map<String, String>> events = mgnData.get("events");
      acctual_1 = events.get(0).get("date");
      acctual_2 = events.get(1).get("date");
      acctual_3 = events.get(2).get("date");
      acctual_99 = events.size();
    }

    assertEquals(
        "getAutoPlantingDate: normal 1st year case with start year", expected_1, acctual_1);
    assertEquals(
        "getAutoPlantingDate: normal 2nd year case with start year", expected_2, acctual_2);
    assertEquals(
        "getAutoPlantingDate: normal 3rd year case with start year", expected_3, acctual_3);
    assertEquals("getAutoPlantingDate: all year with auto-planting case", expected_99, acctual_99);
  }