@Test @Ignore public void testGetBuildToBeInspectedWithPassingBuildWithPreviousPassingBuildBears() { long buildIdPassing = 323802157; long buildIdNextPassing = 323823511; RepairnatorConfig config = RepairnatorConfig.getInstance(); config.setLauncherMode(LauncherMode.BEARS); Optional<Build> buildOptional = config.getJTravis().build().fromId(buildIdPassing); assertTrue(buildOptional.isPresent()); Build buildPassing = buildOptional.get(); assertEquals(StateType.PASSED, buildPassing.getState()); buildOptional = config.getJTravis().build().fromId(buildIdNextPassing); assertTrue(buildOptional.isPresent()); Build buildNextPassing = buildOptional.get(); assertEquals(StateType.PASSED, buildNextPassing.getState()); ProjectScanner projectScanner = new ProjectScanner(new Date(), new Date(), "test"); BuildToBeInspected obtainedBTB = projectScanner.getBuildToBeInspected(buildNextPassing); assertEquals(null, obtainedBTB); }
public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId); } else { this.logger.debug("Build "+build.getId()+" seems interesting to be inspected, thus get its previous build..."); Optional<Build> optionalBeforeBuild = this.jTravis.build().getBefore(build, true); if (optionalBeforeBuild.isPresent()) { Build previousBuild = optionalBeforeBuild.get(); previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); this.logger.debug("Previous build: " + previousBuild.getId()); BearsMode mode = RepairnatorConfig.getInstance().getBearsMode(); if ((mode == BearsMode.BOTH || mode == BearsMode.FAILING_PASSING) && previousBuild.getState() == StateType.FAILED && thereIsDiffOnJavaFile(build, previousBuild) && isFailedBuildFailingByTestFailure(previousBuild)) { this.totalNumberOfFailingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.FAILING_AND_PASSING, this.runId); } else { if ((mode == BearsMode.BOTH || mode == BearsMode.PASSING_PASSING) && previousBuild.getState() == StateType.PASSED && thereIsDiffOnJavaFile(build, previousBuild) && thereIsDiffOnTests(build, previousBuild)) { this.totalNumberOfPassingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, this.runId); } else { this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is NOT interesting to be inspected."); } } } else { this.logger.debug("The previous build from "+build.getId()+" was not retrieved."); } } } else { this.logger.debug("Build "+build.getId()+" is not interesting to be inspected."); } return null; }
ProjectScanner { public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId); } else { this.logger.debug("Build "+build.getId()+" seems interesting to be inspected, thus get its previous build..."); Optional<Build> optionalBeforeBuild = this.jTravis.build().getBefore(build, true); if (optionalBeforeBuild.isPresent()) { Build previousBuild = optionalBeforeBuild.get(); previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); this.logger.debug("Previous build: " + previousBuild.getId()); BearsMode mode = RepairnatorConfig.getInstance().getBearsMode(); if ((mode == BearsMode.BOTH || mode == BearsMode.FAILING_PASSING) && previousBuild.getState() == StateType.FAILED && thereIsDiffOnJavaFile(build, previousBuild) && isFailedBuildFailingByTestFailure(previousBuild)) { this.totalNumberOfFailingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.FAILING_AND_PASSING, this.runId); } else { if ((mode == BearsMode.BOTH || mode == BearsMode.PASSING_PASSING) && previousBuild.getState() == StateType.PASSED && thereIsDiffOnJavaFile(build, previousBuild) && thereIsDiffOnTests(build, previousBuild)) { this.totalNumberOfPassingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, this.runId); } else { this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is NOT interesting to be inspected."); } } } else { this.logger.debug("The previous build from "+build.getId()+" was not retrieved."); } } } else { this.logger.debug("Build "+build.getId()+" is not interesting to be inspected."); } return null; } }
ProjectScanner { public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId); } else { this.logger.debug("Build "+build.getId()+" seems interesting to be inspected, thus get its previous build..."); Optional<Build> optionalBeforeBuild = this.jTravis.build().getBefore(build, true); if (optionalBeforeBuild.isPresent()) { Build previousBuild = optionalBeforeBuild.get(); previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); this.logger.debug("Previous build: " + previousBuild.getId()); BearsMode mode = RepairnatorConfig.getInstance().getBearsMode(); if ((mode == BearsMode.BOTH || mode == BearsMode.FAILING_PASSING) && previousBuild.getState() == StateType.FAILED && thereIsDiffOnJavaFile(build, previousBuild) && isFailedBuildFailingByTestFailure(previousBuild)) { this.totalNumberOfFailingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.FAILING_AND_PASSING, this.runId); } else { if ((mode == BearsMode.BOTH || mode == BearsMode.PASSING_PASSING) && previousBuild.getState() == StateType.PASSED && thereIsDiffOnJavaFile(build, previousBuild) && thereIsDiffOnTests(build, previousBuild)) { this.totalNumberOfPassingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, this.runId); } else { this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is NOT interesting to be inspected."); } } } else { this.logger.debug("The previous build from "+build.getId()+" was not retrieved."); } } } else { this.logger.debug("Build "+build.getId()+" is not interesting to be inspected."); } return null; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); }
ProjectScanner { public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId); } else { this.logger.debug("Build "+build.getId()+" seems interesting to be inspected, thus get its previous build..."); Optional<Build> optionalBeforeBuild = this.jTravis.build().getBefore(build, true); if (optionalBeforeBuild.isPresent()) { Build previousBuild = optionalBeforeBuild.get(); previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); this.logger.debug("Previous build: " + previousBuild.getId()); BearsMode mode = RepairnatorConfig.getInstance().getBearsMode(); if ((mode == BearsMode.BOTH || mode == BearsMode.FAILING_PASSING) && previousBuild.getState() == StateType.FAILED && thereIsDiffOnJavaFile(build, previousBuild) && isFailedBuildFailingByTestFailure(previousBuild)) { this.totalNumberOfFailingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.FAILING_AND_PASSING, this.runId); } else { if ((mode == BearsMode.BOTH || mode == BearsMode.PASSING_PASSING) && previousBuild.getState() == StateType.PASSED && thereIsDiffOnJavaFile(build, previousBuild) && thereIsDiffOnTests(build, previousBuild)) { this.totalNumberOfPassingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, this.runId); } else { this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is NOT interesting to be inspected."); } } } else { this.logger.debug("The previous build from "+build.getId()+" was not retrieved."); } } } else { this.logger.debug("Build "+build.getId()+" is not interesting to be inspected."); } return null; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); String getRunId(); int getTotalRepoNumber(); int getTotalRepoUsingTravis(); int getTotalScannedBuilds(); int getTotalPRBuilds(); int getTotalBuildInJava(); int getTotalJavaPassingBuilds(); int getTotalBuildInJavaFailing(); int getTotalBuildInJavaFailingWithFailingTests(); int getTotalNumberOfFailingAndPassingBuildPairs(); int getTotalNumberOfPassingAndPassingBuildPairs(); Date getLookFromDate(); Date getLookToDate(); Date getScannerRunningBeginDate(); Date getScannerRunningEndDate(); String getScannerDuration(); Map<ScannedBuildStatus, List<BuildToBeInspected>> getListOfBuildsToBeInspectedFromProjects(String path); Map<ScannedBuildStatus, List<BuildToBeInspected>> getBuildsGivenSlug(String slug); BuildToBeInspected getBuildToBeInspected(Build build); }
ProjectScanner { public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId); } else { this.logger.debug("Build "+build.getId()+" seems interesting to be inspected, thus get its previous build..."); Optional<Build> optionalBeforeBuild = this.jTravis.build().getBefore(build, true); if (optionalBeforeBuild.isPresent()) { Build previousBuild = optionalBeforeBuild.get(); previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); this.logger.debug("Previous build: " + previousBuild.getId()); BearsMode mode = RepairnatorConfig.getInstance().getBearsMode(); if ((mode == BearsMode.BOTH || mode == BearsMode.FAILING_PASSING) && previousBuild.getState() == StateType.FAILED && thereIsDiffOnJavaFile(build, previousBuild) && isFailedBuildFailingByTestFailure(previousBuild)) { this.totalNumberOfFailingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.FAILING_AND_PASSING, this.runId); } else { if ((mode == BearsMode.BOTH || mode == BearsMode.PASSING_PASSING) && previousBuild.getState() == StateType.PASSED && thereIsDiffOnJavaFile(build, previousBuild) && thereIsDiffOnTests(build, previousBuild)) { this.totalNumberOfPassingAndPassingBuildPairs++; this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is interesting to be inspected."); return new BuildToBeInspected(previousBuild, build, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, this.runId); } else { this.logger.debug("The pair "+previousBuild.getId()+" ["+previousBuild.getState()+"], "+build.getId()+" ["+build.getState()+"] is NOT interesting to be inspected."); } } } else { this.logger.debug("The previous build from "+build.getId()+" was not retrieved."); } } } else { this.logger.debug("Build "+build.getId()+" is not interesting to be inspected."); } return null; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); String getRunId(); int getTotalRepoNumber(); int getTotalRepoUsingTravis(); int getTotalScannedBuilds(); int getTotalPRBuilds(); int getTotalBuildInJava(); int getTotalJavaPassingBuilds(); int getTotalBuildInJavaFailing(); int getTotalBuildInJavaFailingWithFailingTests(); int getTotalNumberOfFailingAndPassingBuildPairs(); int getTotalNumberOfPassingAndPassingBuildPairs(); Date getLookFromDate(); Date getLookToDate(); Date getScannerRunningBeginDate(); Date getScannerRunningEndDate(); String getScannerDuration(); Map<ScannedBuildStatus, List<BuildToBeInspected>> getListOfBuildsToBeInspectedFromProjects(String path); Map<ScannedBuildStatus, List<BuildToBeInspected>> getBuildsGivenSlug(String slug); BuildToBeInspected getBuildToBeInspected(Build build);  }