### Question:
EclairLogger { public void logOutIfNecessary(MethodInvocation invocation, MethodLog methodLog, Object result) { if (isLogOutNecessary(invocation, methodLog)) { logOut(invocation, methodLog, result); } }  void logInIfNecessary(MethodInvocation invocation, MethodLog methodLog); void logOutIfNecessary(MethodInvocation invocation, MethodLog methodLog, Object result); void logErrorIfNecessary(MethodInvocation invocation, MethodLog methodLog, Throwable throwable);  }### Answer:
@Test public void logOutIfNecessary() { EclairLogger eclairLogger = spy(EclairLogger.class); MethodLog methodLog = mock(MethodLog.class); when(methodLog.getOutLog()).thenReturn(mock(OutLog.class)); eclairLogger.logOutIfNecessary(invocation, methodLog, result); verify(eclairLogger).logOut(eq(invocation), eq(methodLog), eq(result)); }