use of org.talend.dataprofiler.core.CorePlugin in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method mockCorePlugin.
public static CorePlugin mockCorePlugin() {
CorePlugin corePlugin = mock(CorePlugin.class);
PowerMockito.mockStatic(CorePlugin.class);
when(CorePlugin.getDefault()).thenReturn(corePlugin);
return corePlugin;
}
use of org.talend.dataprofiler.core.CorePlugin in project tdq-studio-se by Talend.
the class WorkspaceResourceHelperTest method testSourceFileHasBeenOpened.
/**
* Test method for
* {@link org.talend.dataprofiler.core.helper.WorkspaceResourceHelper#sourceFileHasBeenOpened(org.talend.repository.model.IRepositoryNode)}
* .
*/
@Test
public void testSourceFileHasBeenOpened() {
SourceFileRepNode fileNode = mock(SourceFileRepNode.class);
CorePlugin cpMock = mock(CorePlugin.class);
PowerMockito.mockStatic(CorePlugin.class);
when(CorePlugin.getDefault()).thenReturn(cpMock);
IWorkbench workbenchMock = mock(IWorkbench.class);
when(cpMock.getWorkbench()).thenReturn(workbenchMock);
IWorkbenchWindow workbenchWindowMock = mock(IWorkbenchWindow.class);
when(workbenchMock.getActiveWorkbenchWindow()).thenReturn(workbenchWindowMock);
IWorkbenchPage workbenchPageMock = mock(IWorkbenchPage.class);
when(workbenchWindowMock.getActivePage()).thenReturn(workbenchPageMock);
IEditorReference editorRefMock = mock(IEditorReference.class);
IEditorReference[] editorRefMocks = new IEditorReference[] { editorRefMock };
when(workbenchPageMock.getEditorReferences()).thenReturn(editorRefMocks);
FileEditorInput fileEditorInputMock = mock(FileEditorInput.class);
try {
when(editorRefMock.getEditorInput()).thenReturn(fileEditorInputMock);
} catch (PartInitException e) {
fail(e.getMessage());
}
IFile nodeFileMock = mock(IFile.class);
// $NON-NLS-1$
stub(method(RepositoryNodeHelper.class, "getIFile", SourceFileRepNode.class)).toReturn(nodeFileMock);
IPath nodeFilePathMock = mock(IPath.class);
when(nodeFileMock.getFullPath()).thenReturn(nodeFilePathMock);
// $NON-NLS-1$
String path = "/abc";
when(nodeFilePathMock.toString()).thenReturn(path);
IFile inputFileMock = mock(IFile.class);
when(fileEditorInputMock.getFile()).thenReturn(inputFileMock);
IPath inputFilePathMock = mock(IPath.class);
when(inputFileMock.getFullPath()).thenReturn(inputFilePathMock);
when(inputFilePathMock.toString()).thenReturn(path);
assertTrue(WorkspaceResourceHelper.sourceFileHasBeenOpened(fileNode));
}
Aggregations