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.hamcrest.MatcherAssert.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.hbtop.screen.top.TopScreenView; 027import org.apache.hadoop.hbase.testclassification.SmallTests; 028import org.junit.jupiter.api.BeforeEach; 029import org.junit.jupiter.api.Tag; 030import org.junit.jupiter.api.Test; 031import org.junit.jupiter.api.extension.ExtendWith; 032import org.mockito.Mock; 033import org.mockito.junit.jupiter.MockitoExtension; 034 035@Tag(SmallTests.TAG) 036@ExtendWith(MockitoExtension.class) 037public class TestHelpScreenPresenter { 038 039 private static final long TEST_REFRESH_DELAY = 5; 040 041 @Mock 042 private HelpScreenView helpScreenView; 043 044 @Mock 045 private TopScreenView topScreenView; 046 047 private HelpScreenPresenter helpScreenPresenter; 048 049 @BeforeEach 050 public void setup() { 051 helpScreenPresenter = 052 new HelpScreenPresenter(helpScreenView, TEST_REFRESH_DELAY, topScreenView); 053 } 054 055 @Test 056 public void testInit() { 057 helpScreenPresenter.init(); 058 verify(helpScreenView).showHelpScreen(eq(TEST_REFRESH_DELAY), argThat(cds -> cds.length == 14)); 059 } 060 061 @Test 062 public void testTransitionToTopScreen() { 063 assertThat(helpScreenPresenter.transitionToNextScreen(), is(topScreenView)); 064 } 065}