PaullService { public GenericAccount emailAuth(String email, String password) { try { return externalRestService.authWithEmailPassword(email, password); } catch (RuntimeException e) { LOGGER.error("[emailAuth] Authentication with generic account {} failed: {}", email, e.getMessage()); return null; } } PaullService(ExternalRestService externalRestService); GenericAccount emailAuth(String email, String password);  }
@Test public void emailAuth() throws RuntimeException { given(externalRestService.authWithEmailPassword("test1@test.fr", "test1password")).willReturn(new GenericAccount()); Assert.assertNotNull(paullService.emailAuth("test1@test.fr", "test1password")); }
@Test public void emailAuthFailed() throws RuntimeException { GenericAccount genericAccount = null; given(externalRestService.authWithEmailPassword("test1@test.fr", "test1password")).willReturn(genericAccount); Assert.assertNull(paullService.emailAuth("test1@test.fr", "test1password")); }