@Test void testOneDecorator() { DoSomething before = mock(DoSomething.class); DoSomething after = mock(DoSomething.class); Runnable runnable = mock(Runnable.class); InOrder inOrder = Mockito.inOrder(before, after, runnable); CompositeTaskDecorator underTest = new CompositeTaskDecorator(List.of(TestDecorator.around(before, after))); Runnable decoratedRunnable = underTest.decorate(runnable); decoratedRunnable.run(); inOrder.verify(before).doSomething(); inOrder.verify(runnable).run(); inOrder.verify(after).doSomething(); }
@Override public Runnable decorate(Runnable runnable) { Runnable decoratedRunnable = requireNonNull(runnable, "runnable is null"); for (TaskDecorator decorator : decorators) { decoratedRunnable = decorator.decorate(decoratedRunnable); } return decoratedRunnable; }
CompositeTaskDecorator implements TaskDecorator { @Override public Runnable decorate(Runnable runnable) { Runnable decoratedRunnable = requireNonNull(runnable, "runnable is null"); for (TaskDecorator decorator : decorators) { decoratedRunnable = decorator.decorate(decoratedRunnable); } return decoratedRunnable; } }
CompositeTaskDecorator implements TaskDecorator { @Override public Runnable decorate(Runnable runnable) { Runnable decoratedRunnable = requireNonNull(runnable, "runnable is null"); for (TaskDecorator decorator : decorators) { decoratedRunnable = decorator.decorate(decoratedRunnable); } return decoratedRunnable; } CompositeTaskDecorator(List<TaskDecorator> decorators); }
CompositeTaskDecorator implements TaskDecorator { @Override public Runnable decorate(Runnable runnable) { Runnable decoratedRunnable = requireNonNull(runnable, "runnable is null"); for (TaskDecorator decorator : decorators) { decoratedRunnable = decorator.decorate(decoratedRunnable); } return decoratedRunnable; } CompositeTaskDecorator(List<TaskDecorator> decorators); @Override Runnable decorate(Runnable runnable); }
CompositeTaskDecorator implements TaskDecorator { @Override public Runnable decorate(Runnable runnable) { Runnable decoratedRunnable = requireNonNull(runnable, "runnable is null"); for (TaskDecorator decorator : decorators) { decoratedRunnable = decorator.decorate(decoratedRunnable); } return decoratedRunnable; } CompositeTaskDecorator(List<TaskDecorator> decorators); @Override Runnable decorate(Runnable runnable);  }