/******************************************************************************* * Copyright (c) 2012-2017 Codenvy, S.A. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ package org.eclipse.che.ide.ext.java.client.navigation.action; import com.google.gwtmockito.GwtMockitoTestRunner; import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant; import org.eclipse.che.ide.ext.java.client.JavaResources; import org.eclipse.che.ide.ext.java.client.action.FileStructureAction; import org.eclipse.che.ide.ext.java.client.navigation.filestructure.FileStructurePresenter; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * @author Valeriy Svydenko */ @RunWith(GwtMockitoTestRunner.class) public class FileStructureActionTest { @Mock private FileStructurePresenter fileStructurePresenter; @Mock private EditorAgent editorAgent; @Mock private JavaLocalizationConstant locale; @Mock private EditorPartPresenter editorPartPresenter; @Mock private JavaResources resources; @InjectMocks private FileStructureAction action; @Before public void setUp() { when(editorAgent.getActiveEditor()).thenReturn(editorPartPresenter); } @Test public void constructorShouldBePerformed() throws Exception { verify(locale).fileStructureActionName(); verify(locale).fileStructureActionDescription(); verify(resources).fileNavigation(); } @Test public void actionShouldBePerformed() throws Exception { ActionEvent e = mock(ActionEvent.class); action.actionPerformed(e); verify(editorAgent).getActiveEditor(); verify(fileStructurePresenter).show(editorPartPresenter); } }