### Question:
DslStepsDumper implements StepsDumper { @Override public void dump(TestScenarioSteps testScenarioSteps, String outputFile) throws IOException { File file = new File(outputFile); try (BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)))) { for (Map<String, String> step : testScenarioSteps) { List<SyntaxDefinitionConfiguration> syntaxDefinitions = Optional.ofNullable(actionConfigurations.get(step.get(EVENT))) .orElseThrow(() -> new IllegalStateException("The step " + step + "has an event that is not present in the configuration" + step.get(EVENT))) .getSyntaxDefinitionConfigurationList(); StringBuilder lineBuilder = new StringBuilder(); lineBuilder.append(step.get(EVENT)).append(": "); for (SyntaxDefinitionConfiguration syntaxDefinition: syntaxDefinitions) { if (syntaxDefinition.getContent() != null) { lineBuilder .append(syntaxDefinition.getContent()) .append(' '); } if (syntaxDefinition.getExposedParameter() != null) { lineBuilder .append(step.get(syntaxDefinition.getExposedParameter())) .append(' '); } } bufferedWriter.write(lineBuilder.toString()); bufferedWriter.newLine(); } } } DslStepsDumper(Map<String, ApplicationActionConfiguration> actionConfigurations); @Override void dump(TestScenarioSteps testScenarioSteps, String outputFile);  }### Answer:
@Test public void dumpsStepsReplacingAliases() throws IOException { Map<String, String> firstStep = new HashMap<>(); firstStep.put(EVENT, loadPageActionName); firstStep.put(aliasUrl, aliasUrlValue); Map<String, String> secondStep = new HashMap<>(); secondStep.put(EVENT, typeInNameInputActionName); secondStep.put(aliasText, aliasTextValue); TestScenarioSteps testScenarioSteps = new TestScenarioSteps(); testScenarioSteps.add(firstStep); testScenarioSteps.add(secondStep); Map<String, ApplicationActionConfiguration> actionConfigurationMap = createAliasesMockConfiguration(); StepsDumper stepsDumper = new DslStepsDumper(actionConfigurationMap); stepsDumper.dump(testScenarioSteps, outputFilename); List<String> lines = Files.readLines(outputFile, Charsets.UTF_8); assertEquals(2, lines.size()); assertEquals("loadPage: Load text-field.html page ", lines.get(0)); assertEquals("typeInNameInput: Type admin in name input ", lines.get(1)); }
@Test public void correctlyHandlesNoAliases() throws IOException { Map<String, String> firstStep = new HashMap<>(); firstStep.put(EVENT, clickLoginButtonActionName); TestScenarioSteps testScenarioSteps = new TestScenarioSteps(); testScenarioSteps.add(firstStep); Map<String, ApplicationActionConfiguration> actionConfigurationMap = createNoAliasesMockConfiguration(); StepsDumper stepsDumper = new DslStepsDumper(actionConfigurationMap); stepsDumper.dump(testScenarioSteps, outputFilename); List<String> lines = Files.readLines(outputFile, Charsets.UTF_8); assertEquals(1, lines.size()); assertEquals("clickLoginButtonActionName: Click login button ", lines.get(0)); }
@Test public void correctlyHandlesTheCaseWhenExposedParameterIsFirst() throws IOException { Map<String, String> firstStep = new HashMap<>(); firstStep.put(EVENT, searchActionName); firstStep.put(aliasSearch, aliasSearchValue); TestScenarioSteps testScenarioSteps = new TestScenarioSteps(); testScenarioSteps.add(firstStep); File outputFile = new File(outputFilename); Map<String, ApplicationActionConfiguration> actionConfigurationMap = createExposedParameterFirstMockConfiguration(); StepsDumper stepsDumper = new DslStepsDumper(actionConfigurationMap); stepsDumper.dump(testScenarioSteps, outputFilename); List<String> lines = Files.readLines(outputFile, Charsets.UTF_8); assertEquals(1, lines.size()); assertEquals("searchTerm: dress ", lines.get(0)); }