1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.hbtop.screen.help;
19
20 import static org.hamcrest.CoreMatchers.is;
21 import static org.junit.Assert.assertThat;
22 import static org.mockito.Mockito.argThat;
23 import static org.mockito.Mockito.eq;
24 import static org.mockito.Mockito.verify;
25
26 import org.apache.hadoop.hbase.hbtop.screen.ScreenView;
27 import org.apache.hadoop.hbase.hbtop.screen.top.TopScreenView;
28 import org.apache.hadoop.hbase.testclassification.SmallTests;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.experimental.categories.Category;
32 import org.junit.runner.RunWith;
33 import org.mockito.ArgumentMatcher;
34 import org.mockito.Mock;
35 import org.mockito.runners.MockitoJUnitRunner;
36
37
38 @Category(SmallTests.class)
39 @RunWith(MockitoJUnitRunner.class)
40 public class TestHelpScreenPresenter {
41
42 private static final long TEST_REFRESH_DELAY = 5;
43
44 @Mock
45 private HelpScreenView helpScreenView;
46
47 @Mock
48 private TopScreenView topScreenView;
49
50 private HelpScreenPresenter helpScreenPresenter;
51
52 @Before
53 public void setup() {
54 helpScreenPresenter = new HelpScreenPresenter(helpScreenView, TEST_REFRESH_DELAY,
55 topScreenView);
56 }
57
58 @Test
59 public void testInit() {
60 helpScreenPresenter.init();
61
62 verify(helpScreenView).showHelpScreen(eq(TEST_REFRESH_DELAY), argThat(
63 new ArgumentMatcher<CommandDescription[]>() {
64 @Override
65 public boolean matches(Object o) {
66 return ((CommandDescription[]) o).length == 14;
67 }
68 }));
69 }
70
71 @Test
72 public void testTransitionToTopScreen() {
73 assertThat(helpScreenPresenter.transitionToNextScreen(), is((ScreenView) topScreenView));
74 }
75 }