@Test public void commandLineSteps() throws Exception { PropertyStore store = new PropertyStore(); store.put("fileName", "test.txt"); PlaceholderResolver resolver = new PlaceholderResolver(store); CommandLineSteps steps = new CommandLineSteps(store, resolver); steps.executeCommand("echo \"Hello\""); steps.executeCommandExpectingFailure("mkdir"); File temporaryDirectory = (File) store.get(CommandLineSteps.TEMPORARY_DIRECTORY); Files.write("Hello", new File(temporaryDirectory, "test.txt"), Charset.defaultCharset()); steps.verifyTemporaryDirectoryHasFiles(Collections.singletonList("test.txt")); steps.verifyTemporaryDirectoryHasFiles(Collections.singletonList("{fileName}")); Files.write("Hello", new File(temporaryDirectory, "test2.txt"), Charset.defaultCharset()); steps.delete("test2.txt"); assertFalse(new File(temporaryDirectory, "test2.txt").exists()); steps.createFile("test3.txt", "Hello"); steps.appendFile("test3.txt", "World"); assertEquals("HelloWorld", Files.readFirstLine(new File(temporaryDirectory, "test3.txt"), Charset.defaultCharset())); steps.move("test3.txt", "test4.txt"); assertFalse(new File(temporaryDirectory, "test3.txt").exists()); assertTrue(new File(temporaryDirectory, "test4.txt").exists()); steps.cleanUp(); assertFalse(new File(temporaryDirectory, "test.txt").exists()); assertFalse(new File(temporaryDirectory, "test4.txt").exists()); assertFalse(temporaryDirectory.exists()); }
public CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver) { this.propertyStore = propertyStore; this.placeholderResolver = placeholderResolver; }
CommandLineSteps { public CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver) { this.propertyStore = propertyStore; this.placeholderResolver = placeholderResolver; } }
CommandLineSteps { public CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver) { this.propertyStore = propertyStore; this.placeholderResolver = placeholderResolver; } CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); }
CommandLineSteps { public CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver) { this.propertyStore = propertyStore; this.placeholderResolver = placeholderResolver; } CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); @When("^" + Phrases.SUBJECT + " executes \"([^\"]+)\", it should fail$") void executeCommandExpectingFailure(String command); @When("^" + Phrases.SUBJECT + " executes \"([^\"]+)\" from \"(.+)\", it should fail$") void executeCommandExpectingFailureFromRelativeLocation(String command, String relativePath); @When("^" + Phrases.SUBJECT + " moves \"(.+)\" to \"(.+)\" in the temporary directory$") void move(String from, String to); @When("^" + Phrases.SUBJECT + " creates \"(.+)\" in (?:a|the) temporary directory with content:$") void createFile(String file, String content); @When("^" + Phrases.SUBJECT + " creates \"(.+)\" in (?:a|the) temporary directory with content as is:$") void createFileWithResolvedContent(String file, String content); void doCreateFile(String file, String content); @When("^" + Phrases.SUBJECT + " appends \"(.+)\" in the temporary directory with content:$") void appendFile(String file, String content); @When("^" + Phrases.SUBJECT + " deletes \"(.+)\" from the temporary directory$") void delete(String file); @When("^" + Phrases.SUBJECT + " executes \"(.+)\" from \"(.+)\" relative to (?:a|the) temporary directory$") void executeCommandFromRelativeLocation(String command, String relativePath); @When("^" + Phrases.SUBJECT + " executes \"(.+)\" from (?:a|the) temporary directory$") void executeCommand(String command); @Then("^the temporary directory should have the files:$") void verifyTemporaryDirectoryHasFiles(List<String> names); @Then("^the temporary directory for \"(.+)\" should have the files:$") void verifySpecificTemporaryDirectoryHasFiles(String subDirectory, List<String> names); @Then("^the command output should not contain \"(.+)\"$") void verifyCommandExecutionResultDoesNotContain(String expectedCommandExecutionResult); @Then("^the command output should contain \"(.+)\"$") void verifyCommandExecutionResultContains(String expectedCommandExecutionResult); @Then("^the command output should be \"(.+)\"$") void verifyCommandExecutionResultIs(String expectedCommandExecutionResult); @After void cleanUp(); }
CommandLineSteps { public CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver) { this.propertyStore = propertyStore; this.placeholderResolver = placeholderResolver; } CommandLineSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); @When("^" + Phrases.SUBJECT + " executes \"([^\"]+)\", it should fail$") void executeCommandExpectingFailure(String command); @When("^" + Phrases.SUBJECT + " executes \"([^\"]+)\" from \"(.+)\", it should fail$") void executeCommandExpectingFailureFromRelativeLocation(String command, String relativePath); @When("^" + Phrases.SUBJECT + " moves \"(.+)\" to \"(.+)\" in the temporary directory$") void move(String from, String to); @When("^" + Phrases.SUBJECT + " creates \"(.+)\" in (?:a|the) temporary directory with content:$") void createFile(String file, String content); @When("^" + Phrases.SUBJECT + " creates \"(.+)\" in (?:a|the) temporary directory with content as is:$") void createFileWithResolvedContent(String file, String content); void doCreateFile(String file, String content); @When("^" + Phrases.SUBJECT + " appends \"(.+)\" in the temporary directory with content:$") void appendFile(String file, String content); @When("^" + Phrases.SUBJECT + " deletes \"(.+)\" from the temporary directory$") void delete(String file); @When("^" + Phrases.SUBJECT + " executes \"(.+)\" from \"(.+)\" relative to (?:a|the) temporary directory$") void executeCommandFromRelativeLocation(String command, String relativePath); @When("^" + Phrases.SUBJECT + " executes \"(.+)\" from (?:a|the) temporary directory$") void executeCommand(String command); @Then("^the temporary directory should have the files:$") void verifyTemporaryDirectoryHasFiles(List<String> names); @Then("^the temporary directory for \"(.+)\" should have the files:$") void verifySpecificTemporaryDirectoryHasFiles(String subDirectory, List<String> names); @Then("^the command output should not contain \"(.+)\"$") void verifyCommandExecutionResultDoesNotContain(String expectedCommandExecutionResult); @Then("^the command output should contain \"(.+)\"$") void verifyCommandExecutionResultContains(String expectedCommandExecutionResult); @Then("^the command output should be \"(.+)\"$") void verifyCommandExecutionResultIs(String expectedCommandExecutionResult); @After void cleanUp();  }