@Test public void GetNextStep_FailAndStepSizeOne_ReturnsAnswer() throws Exception { BisectStep currentStep = new BisectStep(0, 1); List<BisectFinishedBuild> history = new ArrayList<BisectFinishedBuild>(); history.add(new BisectFinishedBuild(new BisectStep(0, 4), false)); history.add(new BisectFinishedBuild(new BisectStep(0, 2), false)); history.add(new BisectFinishedBuild(new BisectStep(0, 1), false)); BisectDecision actual = BisectHelper.getNextStep(history, currentStep); assertTrue(actual.isSolved()); assertEquals(actual.getAnswer(), 0); }
public static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep) { if (history.isEmpty()) { if (currentStep.size() == 1) { return BisectDecision.solved(currentStep.getMid()); } return BisectDecision.nextStep(currentStep); } BisectFinishedBuild lastBuild = history.get(history.size() - 1); if (lastBuild.isSuccess()) { BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), true); if (nextStep == null) { BisectFinishedBuild lastFailed = getLastFailed(history); if (lastFailed == null) { return null; } else { return BisectDecision.solved(lastFailed.getMid()); } } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), false); if (nextStep == null) { return BisectDecision.solved(currentStep.getMid()); } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; }
BisectHelper { public static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep) { if (history.isEmpty()) { if (currentStep.size() == 1) { return BisectDecision.solved(currentStep.getMid()); } return BisectDecision.nextStep(currentStep); } BisectFinishedBuild lastBuild = history.get(history.size() - 1); if (lastBuild.isSuccess()) { BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), true); if (nextStep == null) { BisectFinishedBuild lastFailed = getLastFailed(history); if (lastFailed == null) { return null; } else { return BisectDecision.solved(lastFailed.getMid()); } } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), false); if (nextStep == null) { return BisectDecision.solved(currentStep.getMid()); } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } }
BisectHelper { public static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep) { if (history.isEmpty()) { if (currentStep.size() == 1) { return BisectDecision.solved(currentStep.getMid()); } return BisectDecision.nextStep(currentStep); } BisectFinishedBuild lastBuild = history.get(history.size() - 1); if (lastBuild.isSuccess()) { BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), true); if (nextStep == null) { BisectFinishedBuild lastFailed = getLastFailed(history); if (lastFailed == null) { return null; } else { return BisectDecision.solved(lastFailed.getMid()); } } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), false); if (nextStep == null) { return BisectDecision.solved(currentStep.getMid()); } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } private  BisectHelper(); }
BisectHelper { public static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep) { if (history.isEmpty()) { if (currentStep.size() == 1) { return BisectDecision.solved(currentStep.getMid()); } return BisectDecision.nextStep(currentStep); } BisectFinishedBuild lastBuild = history.get(history.size() - 1); if (lastBuild.isSuccess()) { BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), true); if (nextStep == null) { BisectFinishedBuild lastFailed = getLastFailed(history); if (lastFailed == null) { return null; } else { return BisectDecision.solved(lastFailed.getMid()); } } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), false); if (nextStep == null) { return BisectDecision.solved(currentStep.getMid()); } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } private  BisectHelper(); static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep); }
BisectHelper { public static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep) { if (history.isEmpty()) { if (currentStep.size() == 1) { return BisectDecision.solved(currentStep.getMid()); } return BisectDecision.nextStep(currentStep); } BisectFinishedBuild lastBuild = history.get(history.size() - 1); if (lastBuild.isSuccess()) { BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), true); if (nextStep == null) { BisectFinishedBuild lastFailed = getLastFailed(history); if (lastFailed == null) { return null; } else { return BisectDecision.solved(lastFailed.getMid()); } } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } BisectStep nextStep = BisectBoundaryHelper.getNextStep(lastBuild.getStep(), false); if (nextStep == null) { return BisectDecision.solved(currentStep.getMid()); } BisectDecision result = new BisectDecision(); result.setSolved(false); result.setNextStep(nextStep); return result; } private  BisectHelper(); static BisectDecision getNextStep(List<BisectFinishedBuild> history, BisectStep currentStep);  }