@Test(expectedExceptions = ConflictException.class) public void shouldNotSendEmailIfInvocationThrowsException() throws Throwable { when(invocation.proceed()).thenThrow(new ConflictException("conflict")); interceptor.invoke(invocation); verifyZeroInteractions(notificationSender); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable, ApiException { Object proceed = invocation.proceed(); String userName; String userEmail; try { final Response response = (Response) proceed; final UserDto createdUser = (UserDto) response.getEntity(); userName = createdUser.getName(); userEmail = createdUser.getEmail(); final String token = (String) invocation.getArguments()[1]; notificationSender.sendNotification(userName, userEmail, token == null); } catch (Exception e) { LOG.warn("Unable to send creation notification email", e); } return proceed; }
CreateUserInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable, ApiException { Object proceed = invocation.proceed(); String userName; String userEmail; try { final Response response = (Response) proceed; final UserDto createdUser = (UserDto) response.getEntity(); userName = createdUser.getName(); userEmail = createdUser.getEmail(); final String token = (String) invocation.getArguments()[1]; notificationSender.sendNotification(userName, userEmail, token == null); } catch (Exception e) { LOG.warn("Unable to send creation notification email", e); } return proceed; } }
CreateUserInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable, ApiException { Object proceed = invocation.proceed(); String userName; String userEmail; try { final Response response = (Response) proceed; final UserDto createdUser = (UserDto) response.getEntity(); userName = createdUser.getName(); userEmail = createdUser.getEmail(); final String token = (String) invocation.getArguments()[1]; notificationSender.sendNotification(userName, userEmail, token == null); } catch (Exception e) { LOG.warn("Unable to send creation notification email", e); } return proceed; }  }
CreateUserInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable, ApiException { Object proceed = invocation.proceed(); String userName; String userEmail; try { final Response response = (Response) proceed; final UserDto createdUser = (UserDto) response.getEntity(); userName = createdUser.getName(); userEmail = createdUser.getEmail(); final String token = (String) invocation.getArguments()[1]; notificationSender.sendNotification(userName, userEmail, token == null); } catch (Exception e) { LOG.warn("Unable to send creation notification email", e); } return proceed; }  @Override Object invoke(MethodInvocation invocation); }
CreateUserInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable, ApiException { Object proceed = invocation.proceed(); String userName; String userEmail; try { final Response response = (Response) proceed; final UserDto createdUser = (UserDto) response.getEntity(); userName = createdUser.getName(); userEmail = createdUser.getEmail(); final String token = (String) invocation.getArguments()[1]; notificationSender.sendNotification(userName, userEmail, token == null); } catch (Exception e) { LOG.warn("Unable to send creation notification email", e); } return proceed; }  @Override Object invoke(MethodInvocation invocation);  }