@Test public void shouldSendAllSnapshotsFileFromDirectoryWhenHasParentDirectory() throws IOException { final CommandLineExecutionContext executionContext = new CommandLineExecutionContext(0); final File root = new File("root"); final File outputFile = new File(root, "output"); final File snapshotsDir = new File("snapshotsDir"); myCtx.checking(new Expectations() {{ oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); will(returnValue(snapshotsDir.getPath())); oneOf(myFileService).listFiles(root); will(returnValue(new File[] { new File("snapshot1"), new File("snapshot2") })); exactly(2).of(myLoggerService).onMessage(with(any(Message.class))); }}); final ResourcePublisher instance = createInstance(); instance.publishAfterBuildArtifactFile(executionContext, outputFile); myCtx.assertIsSatisfied(); }
@Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) { final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); if(StringUtil.isEmptyOrSpaces(snapshotsTargetDirectoryStr)) { return; } final List<File> snapshots = new ArrayList<File>(); final File parentDir = file.getParentFile(); if(parentDir == null) { snapshots.add(file); } else { snapshots.addAll(Arrays.asList(myFileService.listFiles(parentDir))); } final File snapshotsTargetDirectory = new File(snapshotsTargetDirectoryStr); for(File snapshot: snapshots) { final String artifactPath = String.format("%s => %s", snapshot.getPath(), snapshotsTargetDirectory.getPath()); myLoggerService.onMessage(new PublishArtifacts(artifactPath)); } }
DotTraceSnapshotsPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) { final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); if(StringUtil.isEmptyOrSpaces(snapshotsTargetDirectoryStr)) { return; } final List<File> snapshots = new ArrayList<File>(); final File parentDir = file.getParentFile(); if(parentDir == null) { snapshots.add(file); } else { snapshots.addAll(Arrays.asList(myFileService.listFiles(parentDir))); } final File snapshotsTargetDirectory = new File(snapshotsTargetDirectoryStr); for(File snapshot: snapshots) { final String artifactPath = String.format("%s => %s", snapshot.getPath(), snapshotsTargetDirectory.getPath()); myLoggerService.onMessage(new PublishArtifacts(artifactPath)); } } }
DotTraceSnapshotsPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) { final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); if(StringUtil.isEmptyOrSpaces(snapshotsTargetDirectoryStr)) { return; } final List<File> snapshots = new ArrayList<File>(); final File parentDir = file.getParentFile(); if(parentDir == null) { snapshots.add(file); } else { snapshots.addAll(Arrays.asList(myFileService.listFiles(parentDir))); } final File snapshotsTargetDirectory = new File(snapshotsTargetDirectoryStr); for(File snapshot: snapshots) { final String artifactPath = String.format("%s => %s", snapshot.getPath(), snapshotsTargetDirectory.getPath()); myLoggerService.onMessage(new PublishArtifacts(artifactPath)); } } DotTraceSnapshotsPublisher(
    @NotNull final LoggerService loggerService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); }
DotTraceSnapshotsPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) { final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); if(StringUtil.isEmptyOrSpaces(snapshotsTargetDirectoryStr)) { return; } final List<File> snapshots = new ArrayList<File>(); final File parentDir = file.getParentFile(); if(parentDir == null) { snapshots.add(file); } else { snapshots.addAll(Arrays.asList(myFileService.listFiles(parentDir))); } final File snapshotsTargetDirectory = new File(snapshotsTargetDirectoryStr); for(File snapshot: snapshots) { final String artifactPath = String.format("%s => %s", snapshot.getPath(), snapshotsTargetDirectory.getPath()); myLoggerService.onMessage(new PublishArtifacts(artifactPath)); } } DotTraceSnapshotsPublisher(
    @NotNull final LoggerService loggerService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); @Override void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file, @NotNull final String content); @Override void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file); }
DotTraceSnapshotsPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) { final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR); if(StringUtil.isEmptyOrSpaces(snapshotsTargetDirectoryStr)) { return; } final List<File> snapshots = new ArrayList<File>(); final File parentDir = file.getParentFile(); if(parentDir == null) { snapshots.add(file); } else { snapshots.addAll(Arrays.asList(myFileService.listFiles(parentDir))); } final File snapshotsTargetDirectory = new File(snapshotsTargetDirectoryStr); for(File snapshot: snapshots) { final String artifactPath = String.format("%s => %s", snapshot.getPath(), snapshotsTargetDirectory.getPath()); myLoggerService.onMessage(new PublishArtifacts(artifactPath)); } } DotTraceSnapshotsPublisher(
    @NotNull final LoggerService loggerService,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService); @Override void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file, @NotNull final String content); @Override void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file);  }