Search in sources :

Example 6 with IEcosComponent

use of org.talend.dataprofiler.ecos.model.IEcosComponent in project tdq-studio-se by Talend.

the class ImportObjectTest method testExtractImportObject.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.action.actions.ImportObject#extractImportObject(org.talend.dataprofiler.ecos.model.IEcosComponent, java.util.List)}
 * .
 */
@Test
public void testExtractImportObject() {
    try {
        IEcosComponent ecosMock = mock(IEcosComponent.class);
        PowerMockito.mockStatic(ComponentInstaller.class);
        File fileMock = mock(File.class);
        when(ComponentInstaller.unzip(anyString(), anyString())).thenReturn(fileMock);
        PowerMockito.mockStatic(FilesUtils.class);
        List<File> objFiles = new ArrayList<File>();
        File objFileMock = mock(File.class);
        objFiles.add(objFileMock);
        List<File> jarFiles = new ArrayList<File>();
        File jarFileMock = mock(File.class);
        jarFiles.add(jarFileMock);
        when(FilesUtils.getAllFilesFromFolder((File) anyObject(), (FilenameFilter) anyObject())).thenReturn(objFiles).thenReturn(jarFiles);
        List<ReturnCode> information = new ArrayList<ReturnCode>();
        List<ImportObject> importObjects = ImportObject.extractImportObject(ecosMock, information);
        assertEquals(importObjects.size(), 1);
        assertEquals(information.size(), 0);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) ReturnCode(org.talend.utils.sugars.ReturnCode) IEcosComponent(org.talend.dataprofiler.ecos.model.IEcosComponent) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with IEcosComponent

use of org.talend.dataprofiler.ecos.model.IEcosComponent in project tdq-studio-se by Talend.

the class ImportObjectTest method testExtractImportObject2.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.action.actions.ImportObject#extractImportObject(org.talend.dataprofiler.ecos.model.IEcosComponent, java.util.List)}
 * .
 */
@Test
public void testExtractImportObject2() {
    try {
        IEcosComponent ecosMock = mock(IEcosComponent.class);
        PowerMockito.mockStatic(ComponentInstaller.class);
        File fileMock = mock(File.class);
        when(ComponentInstaller.unzip(anyString(), anyString())).thenReturn(fileMock);
        PowerMockito.mockStatic(FilesUtils.class);
        List<File> objFiles = new ArrayList<File>();
        when(FilesUtils.getAllFilesFromFolder((File) anyObject(), (FilenameFilter) anyObject())).thenReturn(objFiles);
        List<ReturnCode> information = new ArrayList<ReturnCode>();
        List<ImportObject> importObjects = ImportObject.extractImportObject(ecosMock, information);
        assertEquals(importObjects.size(), 0);
        assertEquals(information.size(), 1);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) IEcosComponent(org.talend.dataprofiler.ecos.model.IEcosComponent) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

IEcosComponent (org.talend.dataprofiler.ecos.model.IEcosComponent)7 ArrayList (java.util.ArrayList)5 ReturnCode (org.talend.utils.sugars.ReturnCode)3 File (java.io.File)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)2 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Job (org.eclipse.core.runtime.jobs.Job)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 EObject (org.eclipse.emf.ecore.EObject)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 IEditorInput (org.eclipse.ui.IEditorInput)1