### Question:
HomingV2 { public void callHoming(BuildingBlockExecution execution) { if (isSniro(execution)) { sniroHomingV2.callSniro(execution); } else { oofHomingV2.callOof(execution); } } @Autowired  HomingV2(OofHomingV2 oofHomingV2, SniroHomingV2 sniroHomingV2); void callHoming(BuildingBlockExecution execution); void processSolution(BuildingBlockExecution execution, String asyncResponse); static final String HOMING_SNIRO; static final String HOMING_OOF; static final String HOMING_SOLUTION; }### Answer:
@Test public void whenHomingSolutionSetToSniroShouldCallSniro() { HashMap<String, Object> userParams = new HashMap<>(); userParams.put(HOMING_SOLUTION, HOMING_SNIRO); BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); OofHomingV2 oofHoming = mock(OofHomingV2.class); SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); homingV2.callHoming(givenExecution); then(sniroHoming).should().callSniro(givenExecution); then(oofHoming).shouldHaveZeroInteractions(); }
@Test public void whenHomingSolutionSetToOofShouldCallOof() { HashMap<String, Object> userParams = new HashMap<>(); userParams.put(HOMING_SOLUTION, HOMING_OOF); BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); OofHomingV2 oofHoming = mock(OofHomingV2.class); SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); homingV2.callHoming(givenExecution); then(oofHoming).should().callOof(givenExecution); then(sniroHoming).shouldHaveZeroInteractions(); }
@Test public void whenHomingSolutionNotSetShouldCallOof() { BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(new HashMap<>()); OofHomingV2 oofHoming = mock(OofHomingV2.class); SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); homingV2.callHoming(givenExecution); then(oofHoming).should().callOof(givenExecution); then(sniroHoming).shouldHaveZeroInteractions(); }