@Test(dataProvider = "parseGenerateContentCases") public void shouldGenerateContent(@Nullable final File checkoutPath, @NotNull final File toolPath, @NotNull final String expectedContent) { final File projectFile = new File("project"); final File snapshotFile = new File(new File("snapshots"), "snapshot.dtp"); final File patternsFile = new File("patterns"); final File reportFile = new File("report"); File path; if(checkoutPath != null) { path = new File(checkoutPath, toolPath.getPath()); } else { path = toolPath; } final File consoleProfilerFile = new File(path, CmdGenerator.DOT_TRACE_EXE_NAME); final File reporterFile = new File(path, CmdGenerator.DOT_TRACE_REPORTER_EXE_NAME); final CommandLineSetup setup = new CommandLineSetup("tool", Collections.<CommandLineArgument>emptyList(), Collections.<CommandLineResource>emptyList()); myCtx.checking(new Expectations() {{ oneOf(myRunnerParametersService).getRunnerParameter(Constants.PATH_VAR); will(returnValue(toolPath.getPath())); allowing(myFileService).getCheckoutDirectory(); will(returnValue(checkoutPath)); oneOf(myFileService).validatePath(consoleProfilerFile); oneOf(myFileService).validatePath(reporterFile); oneOf(myCommandLineArgumentsService).createCommandLineString(Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(projectFile.getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(snapshotFile.getPath(), CommandLineArgument.Type.PARAMETER))); will(returnValue("ProfilerCmd")); oneOf(myCommandLineArgumentsService).createCommandLineString(Arrays.asList( new CommandLineArgument(reporterFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(snapshotFile.getParentFile().getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + patternsFile.getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + reportFile.getPath(), CommandLineArgument.Type.PARAMETER))); will(returnValue("ReporterCmd")); }}); final CmdGenerator instance = createInstance(); final String content = instance.create(new Context(setup, projectFile, snapshotFile, patternsFile, reportFile)); myCtx.assertIsSatisfied(); then(content.trim().replace("\n", "").replace("\r", "")).isEqualTo(expectedContent.trim().replace("\n", "").replace("\r", "")); }
@NotNull @Override public String create(@NotNull final Context ctx) { File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR)); if(!dotTracePath.isAbsolute()) { dotTracePath = new File(myFileService.getCheckoutDirectory(), dotTracePath.getPath()); } File consoleProfilerFile = new File(dotTracePath, DOT_TRACE_EXE_NAME); myFileService.validatePath(consoleProfilerFile); File reporterPath = new File(dotTracePath, DOT_TRACE_REPORTER_EXE_NAME); myFileService.validatePath(reporterPath); final StringBuilder cmdLines = new StringBuilder(); cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(ctx.getProjectFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(ctx.getSnapshotFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@SET EXIT_CODE=%ERRORLEVEL%"); cmdLines.append(ourLineSeparator); File stapshotDir = ctx.getSnapshotFile().getParentFile(); if(stapshotDir == null) { stapshotDir = new File("."); } cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(reporterPath.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(stapshotDir.getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + ctx.getPatternsFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + ctx.getReportFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@EXIT %EXIT_CODE%"); cmdLines.append(ourLineSeparator); return cmdLines.toString(); }
CmdGenerator implements ResourceGenerator<Context> { @NotNull @Override public String create(@NotNull final Context ctx) { File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR)); if(!dotTracePath.isAbsolute()) { dotTracePath = new File(myFileService.getCheckoutDirectory(), dotTracePath.getPath()); } File consoleProfilerFile = new File(dotTracePath, DOT_TRACE_EXE_NAME); myFileService.validatePath(consoleProfilerFile); File reporterPath = new File(dotTracePath, DOT_TRACE_REPORTER_EXE_NAME); myFileService.validatePath(reporterPath); final StringBuilder cmdLines = new StringBuilder(); cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(ctx.getProjectFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(ctx.getSnapshotFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@SET EXIT_CODE=%ERRORLEVEL%"); cmdLines.append(ourLineSeparator); File stapshotDir = ctx.getSnapshotFile().getParentFile(); if(stapshotDir == null) { stapshotDir = new File("."); } cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(reporterPath.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(stapshotDir.getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + ctx.getPatternsFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + ctx.getReportFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@EXIT %EXIT_CODE%"); cmdLines.append(ourLineSeparator); return cmdLines.toString(); } }
CmdGenerator implements ResourceGenerator<Context> { @NotNull @Override public String create(@NotNull final Context ctx) { File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR)); if(!dotTracePath.isAbsolute()) { dotTracePath = new File(myFileService.getCheckoutDirectory(), dotTracePath.getPath()); } File consoleProfilerFile = new File(dotTracePath, DOT_TRACE_EXE_NAME); myFileService.validatePath(consoleProfilerFile); File reporterPath = new File(dotTracePath, DOT_TRACE_REPORTER_EXE_NAME); myFileService.validatePath(reporterPath); final StringBuilder cmdLines = new StringBuilder(); cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(ctx.getProjectFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(ctx.getSnapshotFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@SET EXIT_CODE=%ERRORLEVEL%"); cmdLines.append(ourLineSeparator); File stapshotDir = ctx.getSnapshotFile().getParentFile(); if(stapshotDir == null) { stapshotDir = new File("."); } cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(reporterPath.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(stapshotDir.getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + ctx.getPatternsFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + ctx.getReportFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@EXIT %EXIT_CODE%"); cmdLines.append(ourLineSeparator); return cmdLines.toString(); } CmdGenerator(
    @NotNull final CommandLineArgumentsService commandLineArgumentsService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); }
CmdGenerator implements ResourceGenerator<Context> { @NotNull @Override public String create(@NotNull final Context ctx) { File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR)); if(!dotTracePath.isAbsolute()) { dotTracePath = new File(myFileService.getCheckoutDirectory(), dotTracePath.getPath()); } File consoleProfilerFile = new File(dotTracePath, DOT_TRACE_EXE_NAME); myFileService.validatePath(consoleProfilerFile); File reporterPath = new File(dotTracePath, DOT_TRACE_REPORTER_EXE_NAME); myFileService.validatePath(reporterPath); final StringBuilder cmdLines = new StringBuilder(); cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(ctx.getProjectFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(ctx.getSnapshotFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@SET EXIT_CODE=%ERRORLEVEL%"); cmdLines.append(ourLineSeparator); File stapshotDir = ctx.getSnapshotFile().getParentFile(); if(stapshotDir == null) { stapshotDir = new File("."); } cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(reporterPath.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(stapshotDir.getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + ctx.getPatternsFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + ctx.getReportFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@EXIT %EXIT_CODE%"); cmdLines.append(ourLineSeparator); return cmdLines.toString(); } CmdGenerator(
    @NotNull final CommandLineArgumentsService commandLineArgumentsService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); @NotNull @Override String create(@NotNull final Context ctx); }
CmdGenerator implements ResourceGenerator<Context> { @NotNull @Override public String create(@NotNull final Context ctx) { File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR)); if(!dotTracePath.isAbsolute()) { dotTracePath = new File(myFileService.getCheckoutDirectory(), dotTracePath.getPath()); } File consoleProfilerFile = new File(dotTracePath, DOT_TRACE_EXE_NAME); myFileService.validatePath(consoleProfilerFile); File reporterPath = new File(dotTracePath, DOT_TRACE_REPORTER_EXE_NAME); myFileService.validatePath(reporterPath); final StringBuilder cmdLines = new StringBuilder(); cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(consoleProfilerFile.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument(ctx.getProjectFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument(ctx.getSnapshotFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@SET EXIT_CODE=%ERRORLEVEL%"); cmdLines.append(ourLineSeparator); File stapshotDir = ctx.getSnapshotFile().getParentFile(); if(stapshotDir == null) { stapshotDir = new File("."); } cmdLines.append( myCommandLineArgumentsService.createCommandLineString( Arrays.asList( new CommandLineArgument(reporterPath.getPath(), CommandLineArgument.Type.TOOL), new CommandLineArgument("report", CommandLineArgument.Type.PARAMETER), new CommandLineArgument(stapshotDir.getPath() + File.separator + "*.dtp", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--pattern=" + ctx.getPatternsFile().getPath(), CommandLineArgument.Type.PARAMETER), new CommandLineArgument("--save-to=" + ctx.getReportFile().getPath(), CommandLineArgument.Type.PARAMETER)))); cmdLines.append(ourLineSeparator); cmdLines.append("@EXIT %EXIT_CODE%"); cmdLines.append(ourLineSeparator); return cmdLines.toString(); } CmdGenerator(
    @NotNull final CommandLineArgumentsService commandLineArgumentsService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); @NotNull @Override String create(@NotNull final Context ctx);  }