package org.chodavarapu.datamill.cucumber;

import com.google.common.io.Files;
import org.junit.Test;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Arrays;

import static org.junit.Assert.assertFalse;

/**
 * @author Ravi Chodavarapu (rchodava@gmail.com)
 */
public class CommandLineStepsTest {
    @Test
    public void executeAndVerifyFiles() throws Exception {
        PropertyStore store = new PropertyStore();
        PlaceholderResolver resolver = new PlaceholderResolver(store);

        CommandLineSteps steps = new CommandLineSteps(store, resolver);

        steps.executeCommand("ping localhost");

        File temporaryDirectory = (File) store.get(CommandLineSteps.TEMPORARY_DIRECTORY);
        Files.write("Hello", new File(temporaryDirectory, "test.txt"), Charset.defaultCharset());

        steps.verifyTemporaryDirectoryHasFiles(Arrays.asList("test.txt"));

        steps.cleanUp();

        assertFalse(new File(temporaryDirectory, "test.txt").exists());
        assertFalse(temporaryDirectory.exists());
    }
}

@@ -434,16 +434,60 @@
 tore();%0A
+        store.put(%22fileName%22, %22test.txt%22);%0A%0A
         
@@ -549,16 +549,16 @@
 store);%0A
-
 %0A       
@@ -657,22 +657,22 @@
 nd(%22
-ping localhost
+echo %5C%22Hello%5C%22
 %22);%0A
@@ -857,24 +857,24 @@
 harset());%0A%0A
-
         step
@@ -935,16 +935,93 @@
 .txt%22));
+%0A        steps.verifyTemporaryDirectoryHasFiles(Arrays.asList(%22%7BfileName%7D%22));
 %0A%0A      

Change executed command to echo