/** Tests that the variables are degribed to csv and that the csv contains the actual values */
  @Test
  public void testDegribVariables() {
    variable.setName(VARIABLE_NAME);
    variable.setMessages(messages);
    variable.setOutputName(OUTPUT_VARIABLE_NAME);
    variables = new ArrayList<DegribVariable>();
    variables.add(variable);
    degrib.setVariables(variables);

    try {
      degrib.degribVariables();
    } catch (IOException e1) {
      System.out.println("Error running degrib executable");
      e1.printStackTrace();
    }
    String[] extensions = {"csv"};
    Collection<File> result = FileUtils.listFiles(outputDirectory, extensions, false);
    int actualCount = result.size();

    assertEquals(messages.size(), actualCount);
    for (Integer m : messages) {
      System.out.println(m);
      String currentFile = outputDirectory.getPath() + "/" + OUTPUT_VARIABLE_NAME + m + ".csv";
      System.out.println(currentFile);
      try {
        assertTrue(
            FileUtils.directoryContains(
                outputDirectory, new File(outputDirectory, OUTPUT_VARIABLE_NAME + m + ".csv")));
      } catch (IOException e) {
        System.out.println("Error accessing directory");
      }
    }
  }
  /**
   * Tests that for a variable that does not exist, the degriber does not stop and nothing is
   * created in the output directory Useful in the case of downloads that fail (will be estimated
   * with older data) that should not be degribed.
   */
  @Test
  public void testDegribVariableNotExists() {
    variable.setName(NON_EXISTING_VARIABLE_NAME);
    variable.setMessages(messages);
    variable.setOutputName(NON_EXISTING_OUTPUT_VARIABLE_NAME);
    variables = new ArrayList<DegribVariable>();
    variables.add(variable);
    degrib.setVariables(variables);

    try {
      degrib.degribVariables();
    } catch (IOException e1) {
      System.out.println("Error running degrib executable");
      e1.printStackTrace();
    }
    String[] extensions = {"csv"};
    Collection<File> result = FileUtils.listFiles(outputDirectory, extensions, false);
    assertEquals(result.size(), COUNT_OF_SUN_FILES);
  }