LogSubscriber { @Before("classAnnotatedWithRxLogSubscriber(joinPoint) && onCompletedMethodExecution()") public void beforeOnCompletedExecution(JoinPoint joinPoint) { stopWatch.stop(); messageManager.printSubscriberOnCompleted(joinPoint.getTarget().getClass().getSimpleName(), stopWatch.getTotalTimeMillis(), counter.tally()); resetCounters(); } LogSubscriber();  LogSubscriber(Counter counter, StopWatch stopWatch, MessageManager messageManager); @Pointcut(CLASS) static boolean classAnnotatedWithRxLogSubscriber(JoinPoint joinPoint); @Pointcut(METHOD_ON_START) void onStartMethodExecution(); @Pointcut(METHOD_ON_NEXT) void onNextMethodExecution(); @Pointcut(METHOD_ON_ERROR) void onErrorMethodExecution(Throwable throwable); @Pointcut(METHOD_ON_COMPLETED) void onCompletedMethodExecution(); @Pointcut(METHOD_REQUEST) void onRequestMethodCall(long numberOfItems); @Pointcut(METHOD_UN_SUBSCRIBE) void onUnsubscribeMethodCall(); @Before("classAnnotatedWithRxLogSubscriber(joinPoint) && onStartMethodExecution()") void beforeOnStartExecution(JoinPoint joinPoint); @Before("classAnnotatedWithRxLogSubscriber(joinPoint) && onNextMethodExecution()") void beforeOnNextExecution(JoinPoint joinPoint); @After(value = "classAnnotatedWithRxLogSubscriber(joinPoint) && onErrorMethodExecution(throwable)", argNames = "joinPoint,throwable") void afterOnErrorExecution(JoinPoint joinPoint, Throwable throwable); @Before("classAnnotatedWithRxLogSubscriber(joinPoint) && onCompletedMethodExecution()") void beforeOnCompletedExecution(JoinPoint joinPoint); @After("classAnnotatedWithRxLogSubscriber(joinPoint) && onUnsubscribeMethodCall()") void afterUnsubscribeMethodCall(JoinPoint joinPoint); @After("classAnnotatedWithRxLogSubscriber(joinPoint) && onRequestMethodCall(numberOfItems)") void afterRequestMethodCall(JoinPoint joinPoint, long numberOfItems);  }
@Test public void printOnCompleteMessageBeforeSubscriberOnCompleteExecution() { logSubscriber.beforeOnCompletedExecution(joinPoint); verify(stopWatch).stop(); verify(messageManager).printSubscriberOnCompleted(eq(subscriber.getClass().getSimpleName()), anyLong(), anyInt()); verify(counter).tally(); verify(counter).clear(); verify(stopWatch).getTotalTimeMillis(); verify(stopWatch).reset(); }