@Test public void shouldPublishAfterBuildArtifactFile() { final File reportFile = new File("report"); final Metrics reportMetrics = new Metrics( Arrays.asList( new Metric("Method1", "100", "33"), new Metric("Method77", "123", "456"), new Metric("MethodAbc2", "99", "22"))); final Metrics thresholdsMetrics = new Metrics( Arrays.asList( new Metric("Method88", "88", "345"), new Metric("Method1", "100", "1000"), new Metric("MethodA", "F22", "F35"))); final CommandLineExecutionContext ctx = new CommandLineExecutionContext(0); myCtx.checking(new Expectations() {{ oneOf(myAfterBuildPublisher).publishAfterBuildArtifactFile(ctx, reportFile); oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.THRESHOLDS_VAR); will(returnValue("thresholds")); oneOf(myThresholdsParser).parse("thresholds"); will(returnValue(thresholdsMetrics)); try { oneOf(myFileService).readAllTextFile(reportFile); } catch (IOException e) { } will(returnValue("report's content")); oneOf(myReportParser).parse("report's content"); will(returnValue(reportMetrics)); oneOf(myLoggerService).onMessage(new StatisticMessage("Method1", "100", "1000", "100", "33")); oneOf(myLoggerService).onMessage(new StatisticMessage("MethodAbc2", "F22", "F35", "99", "22")); }}); final ResourcePublisher instance = createInstance(); instance.publishAfterBuildArtifactFile(ctx, reportFile); myCtx.assertIsSatisfied(); }
@Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile) { myAfterBuildPublisher.publishAfterBuildArtifactFile(commandLineExecutionContext, reportFile); Metrics thresholdValues; String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR); if(!StringUtil.isEmptyOrSpaces(thresholdsStr)) { thresholdValues = myThresholdsParser.parse(thresholdsStr); } else { return; } try { final String reportContent = myFileService.readAllTextFile(reportFile); final Metrics measuredValues = myReportParser.parse(reportContent); for (Metric measuredValue : measuredValues.getMetrics()) { for (final Metric thresholdValue : thresholdValues.getMetrics()) { if(measuredValue.getMethodName().startsWith(thresholdValue.getMethodName())) { myLoggerService.onMessage(new StatisticMessage(measuredValue.getMethodName(), thresholdValue.getTotalTime(), thresholdValue.getOwnTime(), measuredValue.getTotalTime(), measuredValue.getOwnTime())); } } } } catch (IOException e) { throw new BuildException(e.getMessage()); } }
BuildPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile) { myAfterBuildPublisher.publishAfterBuildArtifactFile(commandLineExecutionContext, reportFile); Metrics thresholdValues; String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR); if(!StringUtil.isEmptyOrSpaces(thresholdsStr)) { thresholdValues = myThresholdsParser.parse(thresholdsStr); } else { return; } try { final String reportContent = myFileService.readAllTextFile(reportFile); final Metrics measuredValues = myReportParser.parse(reportContent); for (Metric measuredValue : measuredValues.getMetrics()) { for (final Metric thresholdValue : thresholdValues.getMetrics()) { if(measuredValue.getMethodName().startsWith(thresholdValue.getMethodName())) { myLoggerService.onMessage(new StatisticMessage(measuredValue.getMethodName(), thresholdValue.getTotalTime(), thresholdValue.getOwnTime(), measuredValue.getTotalTime(), measuredValue.getOwnTime())); } } } } catch (IOException e) { throw new BuildException(e.getMessage()); } } }
BuildPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile) { myAfterBuildPublisher.publishAfterBuildArtifactFile(commandLineExecutionContext, reportFile); Metrics thresholdValues; String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR); if(!StringUtil.isEmptyOrSpaces(thresholdsStr)) { thresholdValues = myThresholdsParser.parse(thresholdsStr); } else { return; } try { final String reportContent = myFileService.readAllTextFile(reportFile); final Metrics measuredValues = myReportParser.parse(reportContent); for (Metric measuredValue : measuredValues.getMetrics()) { for (final Metric thresholdValue : thresholdValues.getMetrics()) { if(measuredValue.getMethodName().startsWith(thresholdValue.getMethodName())) { myLoggerService.onMessage(new StatisticMessage(measuredValue.getMethodName(), thresholdValue.getTotalTime(), thresholdValue.getOwnTime(), measuredValue.getTotalTime(), measuredValue.getOwnTime())); } } } } catch (IOException e) { throw new BuildException(e.getMessage()); } } BuildPublisher(
    @NotNull final TextParser<Metrics> reportParser,
    @NotNull final TextParser<Metrics> thresholdsParser,
    @NotNull final ResourcePublisher afterBuildPublisher,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService,
    @NotNull final LoggerService loggerService); }
BuildPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile) { myAfterBuildPublisher.publishAfterBuildArtifactFile(commandLineExecutionContext, reportFile); Metrics thresholdValues; String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR); if(!StringUtil.isEmptyOrSpaces(thresholdsStr)) { thresholdValues = myThresholdsParser.parse(thresholdsStr); } else { return; } try { final String reportContent = myFileService.readAllTextFile(reportFile); final Metrics measuredValues = myReportParser.parse(reportContent); for (Metric measuredValue : measuredValues.getMetrics()) { for (final Metric thresholdValue : thresholdValues.getMetrics()) { if(measuredValue.getMethodName().startsWith(thresholdValue.getMethodName())) { myLoggerService.onMessage(new StatisticMessage(measuredValue.getMethodName(), thresholdValue.getTotalTime(), thresholdValue.getOwnTime(), measuredValue.getTotalTime(), measuredValue.getOwnTime())); } } } } catch (IOException e) { throw new BuildException(e.getMessage()); } } BuildPublisher(
    @NotNull final TextParser<Metrics> reportParser,
    @NotNull final TextParser<Metrics> thresholdsParser,
    @NotNull final ResourcePublisher afterBuildPublisher,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService,
    @NotNull final LoggerService loggerService); @Override void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File file, @NotNull final String content); @Override void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile); }
BuildPublisher implements ResourcePublisher { @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile) { myAfterBuildPublisher.publishAfterBuildArtifactFile(commandLineExecutionContext, reportFile); Metrics thresholdValues; String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR); if(!StringUtil.isEmptyOrSpaces(thresholdsStr)) { thresholdValues = myThresholdsParser.parse(thresholdsStr); } else { return; } try { final String reportContent = myFileService.readAllTextFile(reportFile); final Metrics measuredValues = myReportParser.parse(reportContent); for (Metric measuredValue : measuredValues.getMetrics()) { for (final Metric thresholdValue : thresholdValues.getMetrics()) { if(measuredValue.getMethodName().startsWith(thresholdValue.getMethodName())) { myLoggerService.onMessage(new StatisticMessage(measuredValue.getMethodName(), thresholdValue.getTotalTime(), thresholdValue.getOwnTime(), measuredValue.getTotalTime(), measuredValue.getOwnTime())); } } } } catch (IOException e) { throw new BuildException(e.getMessage()); } } BuildPublisher(
    @NotNull final TextParser<Metrics> reportParser,
    @NotNull final TextParser<Metrics> thresholdsParser,
    @NotNull final ResourcePublisher afterBuildPublisher,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService,
    @NotNull final LoggerService loggerService); @Override void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File file, @NotNull final String content); @Override void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext commandLineExecutionContext, @NotNull final File reportFile);  }