m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java
blob: 1da50ad1de43ac2b79ff2c5b14e7c138597abfc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package pl.edu.mimuw.cloudatlas.agent;

import java.util.concurrent.LinkedBlockingQueue;

import pl.edu.mimuw.cloudatlas.agent.modules.Module;
import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage;

/*
 * Instead of passing messages to an EventBus, this one just collects them
 * locally for inspection in unit tests.
 */
public class MockExecutor extends Executor {
    public LinkedBlockingQueue<AgentMessage> messagesToPass;

    public MockExecutor(Module module) {
        super(module);
        messagesToPass = new LinkedBlockingQueue<AgentMessage>();
    }

    @Override
    public void passMessage(AgentMessage message) throws InterruptedException {
        messagesToPass.put(message);
    }
}