@Test public void testLoginOk() { when(loginService.login(userForm)).thenReturn(true); assertEquals("OK", loginController.login(userForm)); verify(loginService).login(userForm); verifyNoMoreInteractions(loginService); }
public String login(UserForm userForm) { log.debug("LoginController.login {}", userForm); try { if (userForm == null) { return "ERROR"; } else if (loginService.login(userForm)) { return "OK"; } else { return "KO"; } } catch (Exception e) { return "ERROR"; } }
LoginController { public String login(UserForm userForm) { log.debug("LoginController.login {}", userForm); try { if (userForm == null) { return "ERROR"; } else if (loginService.login(userForm)) { return "OK"; } else { return "KO"; } } catch (Exception e) { return "ERROR"; } } }
LoginController { public String login(UserForm userForm) { log.debug("LoginController.login {}", userForm); try { if (userForm == null) { return "ERROR"; } else if (loginService.login(userForm)) { return "OK"; } else { return "KO"; } } catch (Exception e) { return "ERROR"; } }  }
LoginController { public String login(UserForm userForm) { log.debug("LoginController.login {}", userForm); try { if (userForm == null) { return "ERROR"; } else if (loginService.login(userForm)) { return "OK"; } else { return "KO"; } } catch (Exception e) { return "ERROR"; } }  String login(UserForm userForm); void logout(UserForm userForm); }
LoginController { public String login(UserForm userForm) { log.debug("LoginController.login {}", userForm); try { if (userForm == null) { return "ERROR"; } else if (loginService.login(userForm)) { return "OK"; } else { return "KO"; } } catch (Exception e) { return "ERROR"; } }  String login(UserForm userForm); void logout(UserForm userForm); public LoginService loginService; }