Search in sources :

Example 6 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class DebuggerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    super.setUp();
    debuggerDescriptor = new DebuggerDescriptor(NAME + " " + VERSION, HOST + ":" + PORT);
    doReturn(locationDto).when(dtoFactory).createDto(LocationDto.class);
    doReturn(breakpointDto).when(dtoFactory).createDto(BreakpointDto.class);
    doReturn(locationDto).when(breakpointDto).getLocation();
    doReturn(messageBus).when(messageBusProvider).getMachineMessageBus();
    doReturn(localStorage).when(localStorageProvider).get();
    doReturn(DEBUG_INFO).when(localStorage).getItem(AbstractDebugger.LOCAL_STORAGE_DEBUGGER_SESSION_KEY);
    doReturn(debugSessionDto).when(dtoFactory).createDtoFromJson(anyString(), eq(DebugSessionDto.class));
    doReturn(Path.valueOf(PATH)).when(file).getLocation();
    debugger = new TestDebugger(service, dtoFactory, localStorageProvider, messageBusProvider, eventBus, activeFileHandler, debuggerManager, notificationManager, "id");
    doReturn(promiseInfo).when(service).getSessionInfo(SESSION_ID);
    doReturn(promiseInfo).when(promiseInfo).then(any(Operation.class));
    // setup messageBus
    verify(eventBus).addHandler(eq(WsAgentStateEvent.TYPE), extServerStateHandlerCaptor.capture());
    extServerStateHandlerCaptor.getValue().onWsAgentStarted(WsAgentStateEvent.createWsAgentStartedEvent());
    debugger.addObserver(observer);
    FileType fileType = mock(FileType.class);
    doReturn("java").when(fileType).getExtension();
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) DebugSessionDto(org.eclipse.che.api.debug.shared.dto.DebugSessionDto) DebuggerDescriptor(org.eclipse.che.ide.debug.DebuggerDescriptor) Operation(org.eclipse.che.api.promises.client.Operation) Before(org.junit.Before)

Example 7 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class EditorTabWidgetTest method virtualFileShouldBeUpdated.

@Test
public void virtualFileShouldBeUpdated() throws Exception {
    EditorInput editorInput = mock(EditorInput.class);
    FileType fileType = mock(FileType.class);
    VirtualFile newFile = mock(VirtualFile.class);
    when(editorPartPresenter.getEditorInput()).thenReturn(editorInput);
    when(fileTypeRegistry.getFileTypeByFile(newFile)).thenReturn(fileType);
    when(fileType.getImage()).thenReturn(icon);
    when(editorInput.getFile()).thenReturn(newFile);
    assertNotEquals(tab.getFile(), newFile);
    tab.update(editorPartPresenter);
    assertEquals(tab.getFile(), newFile);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) FileType(org.eclipse.che.ide.api.filetypes.FileType) EditorInput(org.eclipse.che.ide.api.editor.EditorInput) Test(org.junit.Test)

Example 8 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class EditorTabWidgetTest method tabIconShouldBeUpdatedWhenMediaTypeChanged.

@Test
public void tabIconShouldBeUpdatedWhenMediaTypeChanged() {
    EditorInput editorInput = mock(EditorInput.class);
    FileType fileType = mock(FileType.class);
    when(editorPartPresenter.getEditorInput()).thenReturn(editorInput);
    when(fileTypeRegistry.getFileTypeByFile(file)).thenReturn(fileType);
    when(fileType.getImage()).thenReturn(icon);
    when(editorInput.getFile()).thenReturn(file);
    tab.update(editorPartPresenter);
    verify(editorPartPresenter, times(2)).getEditorInput();
    verify(fileTypeRegistry).getFileTypeByFile(file);
    verify(tab.iconPanel).setWidget(Matchers.<SVGImage>anyObject());
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) EditorInput(org.eclipse.che.ide.api.editor.EditorInput) Test(org.junit.Test)

Example 9 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class RecipeEditorPanelTest method editorShouldBeInitializedAndShowed.

@Test
public void editorShouldBeInitializedAndShowed() throws Exception {
    FileType fileType = mock(FileType.class);
    when(fileTypeRegistry.getFileTypeByFile(recipeFile)).thenReturn(fileType);
    presenter.showEditor();
    verify(recipeDescriptor).getScript();
    verify(recipeFileFactory).newInstance(SOME_TEXT);
    verify(orionTextEditorFactory).get();
    verify(editor).activate();
    verify(editor).onOpen();
    verify(view).showEditor(editor);
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) Test(org.junit.Test)

Example 10 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class RecipeEditorPanelTest method editorShouldBeShowed.

@Test
public void editorShouldBeShowed() throws Exception {
    FileType fileType = mock(FileType.class);
    when(fileTypeRegistry.getFileTypeByFile(recipeFile)).thenReturn(fileType);
    presenter.showEditor();
    presenter.showEditor();
    verify(recipeDescriptor).getScript();
    verify(recipeFileFactory).newInstance(SOME_TEXT);
    verify(orionTextEditorFactory).get();
    verify(editor).activate();
    verify(editor).onOpen();
    verify(view).showEditor(editor);
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) Test(org.junit.Test)

Aggregations

FileType (org.eclipse.che.ide.api.filetypes.FileType)12 Test (org.junit.Test)5 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)3 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 EditorInput (org.eclipse.che.ide.api.editor.EditorInput)2 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)2 Before (org.junit.Before)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Inject (com.google.inject.Inject)1 List (java.util.List)1 Logger (java.util.logging.Logger)1 DebugSessionDto (org.eclipse.che.api.debug.shared.dto.DebugSessionDto)1 LanguageDescriptionDTO (org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 AsyncEditorProvider (org.eclipse.che.ide.api.editor.AsyncEditorProvider)1 EditorProvider (org.eclipse.che.ide.api.editor.EditorProvider)1 OpenEditorCallbackImpl (org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl)1 Document (org.eclipse.che.ide.api.editor.document.Document)1