Search in sources :

Example 56 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactoryTest method testFullMatch.

@Test
public void testFullMatch() {
    IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
    String keyword = "tjava";
    List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
    /**
         * NOTE: the expect result may change if we add/change some new components in someday
         */
    assert (componentHits.get(0).getName().equals(TJAVA));
    assert (1 < componentHits.size());
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Example 57 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactoryTest method assertExistedComponent.

private void assertExistedComponent(String compName, String keywords, List<IComponent> componentHits) {
    boolean found = false;
    for (IComponent comp : componentHits) {
        if (comp.getName().equals(compName)) {
            found = true;
            break;
        }
    }
    Assert.assertTrue("Can't find the keywords \"" + keywords + "\" for component: " + compName, found);
}
Also used : IComponent(org.talend.core.model.components.IComponent)

Example 58 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactoryTest method testSortResultBasedOnRecentlyUsed.

@Test
public void testSortResultBasedOnRecentlyUsed() {
    final String component1 = "component1";
    final String component2 = "component2";
    final String component3 = "component3";
    List<RecentlyUsedComponent> recentlyUsedList = new ArrayList<RecentlyUsedComponent>(3);
    RecentlyUsedComponent urc = new RecentlyUsedComponent();
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    urc.setName(component1);
    gregorianCalendar.set(2016, 7, 20);
    urc.setTimestamp(gregorianCalendar.getTime());
    recentlyUsedList.add(urc);
    urc = new RecentlyUsedComponent();
    urc.setName(component2);
    gregorianCalendar.set(2016, 7, 22);
    urc.setTimestamp(gregorianCalendar.getTime());
    recentlyUsedList.add(urc);
    urc = new RecentlyUsedComponent();
    urc.setName(component3);
    gregorianCalendar.set(2016, 7, 21);
    urc.setTimestamp(gregorianCalendar.getTime());
    recentlyUsedList.add(urc);
    TalendEditorPaletteFactory.storeRecentlyUsedList(recentlyUsedList);
    IComponent comp1 = new DummyComponent(component1, component1 + " long name");
    IComponent comp2 = new DummyComponent(component2, component2 + " long name");
    IComponent comp3 = new DummyComponent(component3, component3 + " long name");
    List<IComponent> componentHits = new ArrayList<IComponent>(3);
    componentHits.add(comp1);
    componentHits.add(comp2);
    componentHits.add(comp3);
    TalendEditorPaletteFactory.sortResultsBasedOnRecentlyUsed(componentHits);
    assert (componentHits.get(0) == comp2);
    assert (componentHits.get(1) == comp3);
    assert (componentHits.get(2) == comp1);
}
Also used : IComponent(org.talend.core.model.components.IComponent) RecentlyUsedComponent(org.talend.designer.core.ui.editor.TalendEditorPaletteFactory.RecentlyUsedComponent) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Example 59 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class TestComponentsAction method initialize.

public void initialize() {
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "Component Test") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // IProgressMonitor monitorWrap = new CodeGeneratorProgressMonitor(monitor);
                //$NON-NLS-1$
                monitor.beginTask("Component Test Running", 1100);
                IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
                Set<IComponent> components = componentsFactory.getComponents();
                monitor.worked(100);
                RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
                ECodeLanguage codeLanguage = repositoryContext.getProject().getLanguage();
                String path = getPath();
                // TODO
                int taskTotal = components.size();
                for (IComponent component : components) {
                    String templateURI = path + File.separatorChar + component.getName() + File.separatorChar + TestParameter.GENERATE_TEST;
                    File templateFile = new File(templateURI);
                    // System.out.println(templateFile + " " + templateFile.exists());
                    if (templateFile.exists()) {
                        File[] fileArray = getFile(templateFile, codeLanguage);
                        //$NON-NLS-1$ //$NON-NLS-2$
                        generateCode(fileArray, templateURI.replace("\\", "/"));
                    }
                    monitor.worked(1 * 1000 / taskTotal);
                }
            } catch (Exception e) {
                //$NON-NLS-1$
                log.error("Exception during test Initialization", e);
            }
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryContext(org.talend.core.context.RepositoryContext) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Job(org.eclipse.core.runtime.jobs.Job) File(java.io.File) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 60 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class ComponentListControllerTest method testrenameComponentUniqueName.

@Test
public void testrenameComponentUniqueName() {
    //---first
    String oldConnectionName = "joblet3_1";
    String newConnectionName = "joblet1_1_joblet2_1_joblet3_1";
    List<Node> nodesToUpdate = new ArrayList<Node>();
    IComponent component = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    Process process = new Process(property);
    Node node = new Node(component, process);
    nodesToUpdate.add(node);
    IElementParameter param = node.getElementParameter("CONNECTION");
    param.setValue("joblet3_1_joblet4_1_joblet5_1_tMysqlConnection_1");
    ComponentListController.renameComponentUniqueName(oldConnectionName, newConnectionName, nodesToUpdate);
    assertTrue(param.getValue().equals("joblet1_1_joblet2_1_joblet3_1_joblet4_1_joblet5_1_tMysqlConnection_1"));
    //---second
    oldConnectionName = "tMysqlConnection_1";
    newConnectionName = "joblet1_1_joblet2_1_tMysqlConnection_1";
    param.setValue("tMysqlConnection_1_joblet4_1_joblet5_1_tMysqlConnection_1");
    ComponentListController.renameComponentUniqueName(oldConnectionName, newConnectionName, nodesToUpdate);
    assertTrue(param.getValue().equals("joblet1_1_joblet2_1_tMysqlConnection_1_joblet4_1_joblet5_1_tMysqlConnection_1"));
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Aggregations

IComponent (org.talend.core.model.components.IComponent)146 Node (org.talend.designer.core.ui.editor.nodes.Node)54 ArrayList (java.util.ArrayList)47 IElementParameter (org.talend.core.model.process.IElementParameter)36 Process (org.talend.designer.core.ui.editor.process.Process)36 Test (org.junit.Test)35 INode (org.talend.core.model.process.INode)33 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)22 List (java.util.List)15 Property (org.talend.core.model.properties.Property)15 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)13 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)12 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 HashMap (java.util.HashMap)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 DataNode (org.talend.designer.core.model.process.DataNode)10 HashSet (java.util.HashSet)9 IConnection (org.talend.core.model.process.IConnection)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8