Project

General

Profile

1
package eu.dnetlib.enabling.tools.blackboard;
2

    
3
import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
4
import org.junit.Before;
5
import org.junit.Test;
6
import org.junit.runner.RunWith;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.test.context.ContextConfiguration;
9
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10

    
11
import static org.junit.Assert.assertNotNull;
12
import static org.mockito.Matchers.anyObject;
13
import static org.mockito.Matchers.eq;
14
import static org.mockito.Mockito.*;
15

    
16
@RunWith(SpringJUnit4ClassRunner.class)
17
@ContextConfiguration
18
public class BlackboardServerActionExecutorTest {
19

    
20
	@Autowired
21
	public BlackboardServerHandler blackboardHandler;
22

    
23
	@Autowired
24
	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
25

    
26
	@Before
27
	public void setUp() throws Exception {
28

    
29
	}
30

    
31
	@Test
32
	public void testExecutor() {
33
		assertNotNull(executor);
34

    
35
		BlackboardJob job = mock(BlackboardJob.class);
36
		when(job.getAction()).thenReturn("CREATE");
37

    
38
		executor.execute(job);
39

    
40
		verify(blackboardHandler).done(eq(job));
41
	}
42

    
43
	@Test
44
	public void testExecutorUnimplemented() {
45
		assertNotNull(executor);
46

    
47
		BlackboardJob job = mock(BlackboardJob.class);
48
		when(job.getAction()).thenReturn("DELETE");
49

    
50
		executor.execute(job);
51

    
52
		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
53
	}
54
}
(1-1/3)