BranchPerformer implements StepPerformer, FlowerSelectedListener { @Override public void doStep() { if (enabled) { if (!paintStepSkipper.hasToSkipStep() && hasFlower()) { paintAndUpdateBranches(); } attemptToBloomBranch(); paintStepSkipper.recordStep(); } } protected  BranchPerformer(InkDrop inkDrop,
                              BranchesList branchesList,
                              FlowerDrawer flowerDrawer,
                              PaintStepSkipper paintStepSkipper,
                              BrushOptionsPreferences brushOptionsPreferences,
                              RainbowDrawer rainbowDrawer,
                              RainbowInputController rainbowInputController); static BranchPerformer newInstance(InkDrop inkDrop,
                                              RainbowDrawer rainbowDrawer,
                                              RainbowInputController rainbowInputController); @Override void init(); @Override void doStep(); @Override void enable(); @Override void disable(); @Override void reset(); @Override void onFlowerSelected(final Flower flower);  }
@Test public void testThatOnDoStepIfPerformerIsEnabledStepIsRecordedOnPaintStepSkipper() { givenThatPerformerIsEnabled(); branchPerformer.doStep(); verify(paintStepSkipper).recordStep(); }
@Test public void testThatOnDoStepIfPerformerIsDisabledStepIsNotRecordedOnPaintStepSkipper() { givenThatPerformerIsDisabled(); branchPerformer.doStep(); verify(paintStepSkipper, never()).recordStep(); }
@Test public void testGivenThatPerformerIsEnabledDoesNotHaveToSkipStepAndHasFlowerThenWhenDoingStepBranchesListIsPrunedIfBranchIsDead() { givenThatPerformerIsEnabled(); givenThatHasNotToSkipStep(); givenThatHasFlowers(); givenThatBranchIsDead(); branchPerformer.doStep(); verify(branchesList).prune(branch); }
@Test public void testGivenThatPerformerIsEnabledHaveToSkipStepAndHasFlowerThenWhenDoingStepBranchesListIsNotPrunedIfBranchIsDead() { givenThatPerformerIsEnabled(); givenThatHasToSkipStep(); givenThatHasFlowers(); givenThatBranchIsDead(); branchPerformer.doStep(); verify(branchesList, never()).prune(any(Branch.class)); }
@Test public void testGivenThatPerformerIsEnabledDoesNotHaveToSkipStepAndHasNoFlowerThenWhenDoingStepBranchesListIsNotPrunedIfBranchIsDead() { givenThatHasNoFlowers(); givenThatPerformerIsEnabled(); givenThatHasNotToSkipStep(); givenThatBranchIsDead(); branchPerformer.doStep(); verify(branchesList, never()).prune(any(Branch.class)); }
@Test public void testGivenThatPerformerIsEnabledDoesNotHaveToSkipStepThenWhenDoingStepBranchIsPainted() { givenThatPerformerIsEnabled(); givenThatHasNotToSkipStep(); givenThatBranchIsNotDead(); branchPerformer.doStep(); verify(rainbowDrawer).line(anyFloat(), anyFloat(), anyFloat(), anyFloat()); }
@Test public void testGivenThatPerformerIsEnabledDoesNotHaveToSkipStepAndHasFlowerThenWhenDoingStepBranchIsPainted() { givenThatPerformerIsEnabled(); givenThatHasNotToSkipStep(); givenThatHasFlowers(); givenThatBranchIsNotDead(); branchPerformer.doStep(); verify(rainbowDrawer).line(anyFloat(), anyFloat(), anyFloat(), anyFloat()); }
@Test public void testGivenThatPerformerIsEnabledDoesNotHaveToSkipStepAndHasFlowerThenWhenDoingStepBranchIsPaintedWithBrushColor() { givenThatPerformerIsEnabled(); givenThatHasNotToSkipStep(); givenThatHasFlowers(); givenThatBranchIsNotDead(); branchPerformer.doStep(); verify(brushOptionsPreferences).getBranchColor(); }
@Test public void testGivenThatPerformerIsEnabledHaveToSkipStepAndHasFlowerThenWhenDoingStepBranchIsNotPainted() { givenThatPerformerIsEnabled(); givenThatHasToSkipStep(); givenThatBranchIsNotDead(); branchPerformer.doStep(); verify(rainbowDrawer, never()).line(anyFloat(), anyFloat(), anyFloat(), anyFloat()); }