title: Test file copy in java
body: <p>I'm trying to implement TDD and code coverage in my new projects but for a current one I am creating some test but I have multiple doubts about it. Here I share the class I created to copy one file from my file system : </p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import java.text.ParseException;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.scheduling.annotation.Scheduled;
  import org.springframework.stereotype.Component;
  
  import com.google.common.io.Files;
  
  @Component
  public class CopyXMLFileToResources {
  
  
      @Value("${xml.routing.folder}")
      private String XML_FOLDER;
  
      @Value("${resources.folder}")
      private String RESOURCES_FOLDER;
  
      private final Logger LOG = LoggerFactory.getLogger(CopyXMLFileToResources.class);
  
      @Scheduled(cron = "${cron.files.copy}", zone = "${zone.files.copy}")
      public void copyXMLFile() throws IOException {
  
      LOG.info("Copying the lastest varsion of  Delta file ...");
  
      File directory = validateDirectory(XML_FOLDER);
  
      if (directory.canRead()) {
  
          try {
  
          File origin = Utils.prepareDeltaFile(directory);
          if (origin != null) {
              File copied = new File(RESOURCES_FOLDER + origin.getName());
              if (copied.getTotalSpace() &gt; 0) {
              LOG.info("Last version already copied.");
              }
              else {
                  try {
                      Files.copy(origin, copied);
                      LOG.info(
                          "Copying the  DELTA file successful");
                  }
                  catch (Exception e) {
                      LOG.error(e.getMessage());
                  }
              }
  
          }
          else {
              LOG.warn("No matching files fouded in {}",
                  directory.getCanonicalPath());
          }
  
          }
          catch (ParseException e) {
          LOG.error(e.getMessage()); 
          }
  
      }
      else {
          LOG.warn("Cannot read folder {}. ", XML_FOLDER);
      }
  
      }
  
      private File validateDirectory (String folder) {
      return new File(folder);
      }
  
      public String printString(String s ) {
      return s;
      }
  
  }
  </code></pre>
  
  <p>I know there are so many things to improve, but my first question is, what  functionalities must be tested and how to start? Because I created a Test class but I do not know what to test, I tryed to start testing the access to the folder but that makes me question about if do I need to return something like a integer code depending of the case for example 0 for Folder access denied, 1 when all is OK for example. 
  This class only have one public method and is a void one. I also have the question about the properties I am using:</p>
  
  <p><code>application.properties</code>:</p>
  
  <pre><code>xml.routing.folder=../../xml
  resources.folder=src/main/resources/
  cron.files.copy=0 1 1 * * *
  zone.files.copy=Europe/Paris
  </code></pre>
  
  <p>Is this correct? If I migrate the project to another server, the access to the folder that contains the xml may be denied. I haven't created Test before so I appreciate resources to start specially in TDD.</p>