@Override public void act(final Goro goro) { goro.getExecutor(queue).execute(command); } }
@Override public void act(final Goro goro) { goro.getExecutor(queue).execute(command); } }
@Override public Executor getExecutor(final String queueName) { synchronized (lock) { if (delegate != null) { return delegate.getExecutor(queueName); } return new PostponeExecutor(queueName); } }
@Override public void execute(@SuppressWarnings("NullableProblems") final Runnable command) { synchronized (lock) { if (service != null) { service.getExecutor(queueName).execute(command); } else { postponed.add(new RunnableData(queueName, command)); } } } }
@Override public Executor getExecutor(final String queueName) { synchronized (lock) { if (service != null) { return service.getExecutor(queueName); } return new PostponeExecutor(queueName); } }
@Override public void execute(@SuppressWarnings("NullableProblems") final Runnable command) { synchronized (lock) { if (delegate != null) { delegate.getExecutor(queueName).execute(command); } else { postponed.add(new ExecutorAction(queueName, command)); } } } }
@Test public void getExecutorShouldReturnExecutorWrapper() { Executor executor = goro.getExecutor("q"); assertThat(executor).isNotNull(); Runnable task = mock(Runnable.class); executor.execute(task); verify(task, never()).run(); //noinspection NullableProblems Executor direct = new Executor() { @Override public void execute(Runnable command) { command.run(); } }; doReturn(direct).when(serviceInstance).getExecutor(anyString()); goro.bind(); verify(task).run(); }