001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.hbtop.screen.help;
019
020import static org.hamcrest.CoreMatchers.is;
021import static org.junit.Assert.assertThat;
022import static org.mockito.ArgumentMatchers.argThat;
023import static org.mockito.ArgumentMatchers.eq;
024import static org.mockito.Mockito.verify;
025
026import org.apache.hadoop.hbase.HBaseClassTestRule;
027import org.apache.hadoop.hbase.hbtop.screen.top.TopScreenView;
028import org.apache.hadoop.hbase.testclassification.SmallTests;
029import org.junit.Before;
030import org.junit.ClassRule;
031import org.junit.Test;
032import org.junit.experimental.categories.Category;
033import org.junit.runner.RunWith;
034import org.mockito.Mock;
035import org.mockito.runners.MockitoJUnitRunner;
036
037
038@Category(SmallTests.class)
039@RunWith(MockitoJUnitRunner.class)
040public class TestHelpScreenPresenter {
041
042  @ClassRule
043  public static final HBaseClassTestRule CLASS_RULE =
044    HBaseClassTestRule.forClass(TestHelpScreenPresenter.class);
045
046  private static final long TEST_REFRESH_DELAY = 5;
047
048  @Mock
049  private HelpScreenView helpScreenView;
050
051  @Mock
052  private TopScreenView topScreenView;
053
054  private HelpScreenPresenter helpScreenPresenter;
055
056  @Before
057  public void setup() {
058    helpScreenPresenter = new HelpScreenPresenter(helpScreenView, TEST_REFRESH_DELAY,
059      topScreenView);
060  }
061
062  @Test
063  public void testInit() {
064    helpScreenPresenter.init();
065    verify(helpScreenView).showHelpScreen(eq(TEST_REFRESH_DELAY), argThat(cds -> cds.length == 14));
066  }
067
068  @Test
069  public void testTransitionToTopScreen() {
070    assertThat(helpScreenPresenter.transitionToNextScreen(), is(topScreenView));
071  }
072}