### Question:
HomingV2 { public void processSolution(BuildingBlockExecution execution, String asyncResponse) { if (isSniro(execution)) { sniroHomingV2.processSolution(execution, asyncResponse); } else { oofHomingV2.processSolution(execution, asyncResponse); } } @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 whenHomingSolutionSetToSniroShouldProcessSniro() { 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.processSolution(givenExecution, "dummy"); then(sniroHoming).should().processSolution(givenExecution, "dummy"); then(oofHoming).shouldHaveZeroInteractions(); }
@Test public void whenHomingSolutionSetToOofShouldProcessOof() { 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.processSolution(givenExecution, "dummy"); then(oofHoming).should().processSolution(givenExecution, "dummy"); then(sniroHoming).shouldHaveZeroInteractions(); }
@Test public void whenHomingSolutionNotSetShouldProcessOof() { BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(new HashMap<>()); OofHomingV2 oofHoming = mock(OofHomingV2.class); SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); homingV2.processSolution(givenExecution, "dummy"); then(oofHoming).should().processSolution(givenExecution, "dummy"); then(sniroHoming).shouldHaveZeroInteractions(); }