Search in sources :

Example 21 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class ModuleNeededComparatorTest method setUp.

@Before
public void setUp() {
    //$NON-NLS-1$
    ModuleNeeded m1 = new ModuleNeeded("c1", MODULE1, EMPTY, false);
    m1.setBundleName(EMPTY);
    //$NON-NLS-1$
    ModuleNeeded m2 = new ModuleNeeded("c2", MODULE1, EMPTY, false);
    m2.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m3 = new ModuleNeeded("c3", MODULE1, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m4 = new ModuleNeeded("c4", MODULE1, EMPTY, true);
    m4.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m5 = new ModuleNeeded("c5", MODULE1, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m6 = new ModuleNeeded("c6", MODULE1, EMPTY, true);
    m6.setMrRequired(true);
    //$NON-NLS-1$
    ModuleNeeded m11 = new ModuleNeeded("c11", MODULE2, EMPTY, false);
    m11.setBundleName(EMPTY);
    //$NON-NLS-1$
    ModuleNeeded m12 = new ModuleNeeded("c12", MODULE2, EMPTY, false);
    m12.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m13 = new ModuleNeeded("c13", MODULE2, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m14 = new ModuleNeeded("c14", MODULE2, EMPTY, true);
    m14.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m15 = new ModuleNeeded("c15", MODULE2, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m16 = new ModuleNeeded("c16", MODULE2, EMPTY, true);
    m16.setMrRequired(true);
    neededModules.add(m11);
    neededModules.add(m3);
    neededModules.add(m2);
    neededModules.add(m12);
    neededModules.add(m16);
    neededModules.add(m5);
    neededModules.add(m4);
    neededModules.add(m1);
    neededModules.add(m15);
    neededModules.add(m13);
    neededModules.add(m6);
    neededModules.add(m14);
    refNeededModules.add(m4);
    refNeededModules.add(m2);
    refNeededModules.add(m1);
    refNeededModules.add(m6);
    refNeededModules.add(m3);
    refNeededModules.add(m5);
    refNeededModules.add(m14);
    refNeededModules.add(m12);
    refNeededModules.add(m11);
    refNeededModules.add(m16);
    refNeededModules.add(m15);
    refNeededModules.add(m13);
    //$NON-NLS-1$
    refMap.put(1, "c4");
    //$NON-NLS-1$
    refMap.put(2, "c2");
    //$NON-NLS-1$
    refMap.put(3, "c1");
    //$NON-NLS-1$
    refMap.put(4, "c6");
    //$NON-NLS-1$
    refMap.put(5, "c3");
    //$NON-NLS-1$
    refMap.put(6, "c5");
    //$NON-NLS-1$
    refMap.put(7, "c14");
    //$NON-NLS-1$
    refMap.put(8, "c12");
    //$NON-NLS-1$
    refMap.put(9, "c11");
    //$NON-NLS-1$
    refMap.put(10, "c16");
    //$NON-NLS-1$
    refMap.put(11, "c15");
    //$NON-NLS-1$
    refMap.put(12, "c13");
}
Also used : ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Before(org.junit.Before)

Example 22 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testFindMoreLibraries.

@Test
public void testFindMoreLibraries() {
    // ensure the CAMEL is not added as jar dependency
    DummyComponent comp = mock(DummyComponent.class);
    when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    IElementParameter param = new ElementParameter(node);
    param.setName("HOTLIBS");
    List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();
    Map<String, Object> line = new HashMap<String, Object>();
    line.put("LIBPATH", "CAMEL");
    table.add(line);
    param.setValue(table);
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertTrue(modulesNeeded.isEmpty());
    table = new ArrayList<Map<String, Object>>();
    line = new HashMap<String, Object>();
    line.put("LIBPATH", "\"camel.jar\"");
    table.add(line);
    param.setValue(table);
    modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertEquals(1, modulesNeeded.size());
    assertEquals("camel.jar", modulesNeeded.get(0).getModuleName());
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 23 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testGetChildrenModules_noChildren.

@Test
public void testGetChildrenModules_noChildren() {
    INode node = mock(INode.class);
    IComponent component = mock(IComponent.class);
    when(node.getComponent()).thenReturn(component);
    when(component.getName()).thenReturn("tLogRow");
    List<ModuleNeeded> childrenModules = JavaProcessUtil.getChildrenModules(node, Collections.emptySet(), false);
    assertTrue(childrenModules.isEmpty());
}
Also used : INode(org.talend.core.model.process.INode) IComponent(org.talend.core.model.components.IComponent) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 24 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class ModuleNeededComparatorTest method compareTest.

@Test
public void compareTest() {
    Collections.sort(neededModules, new ModuleNeededComparator());
    assertEquals(neededModules, refNeededModules);
    Iterator<ModuleNeeded> iter = neededModules.iterator();
    boolean ok = true;
    int index = 1;
    while (iter.hasNext()) {
        ModuleNeeded mn = iter.next();
        if (mn.getContext() == null || !mn.getContext().equals(refMap.get(index))) {
            ok = false;
            break;
        }
        index++;
    }
    assertTrue(ok);
}
Also used : ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 25 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JavaProcessorUtilitiesTest method testComputeLibrariesPathWithMissingJars.

@Test
public void testComputeLibrariesPathWithMissingJars() {
    boolean headless = CommonsPlugin.isHeadless();
    try {
        // don't popup dialog to block ui
        CommonsPlugin.setHeadless(true);
        IComponent tLibraryLoadComponent = ComponentsFactoryProvider.getInstance().get("tLibraryLoad", ComponentCategory.CATEGORY_4_DI.getName());
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        //$NON-NLS-1$
        property.setId("property");
        //$NON-NLS-1$
        property.setVersion("0.1");
        //$NON-NLS-1$
        property.setLabel("test");
        Process process = new Process(property);
        Node tLibraryLoad_1 = new Node(tLibraryLoadComponent, process);
        process.addNodeContainer(new NodeContainer(tLibraryLoad_1));
        tLibraryLoad_1.getElementParameter("LIBRARY").setValue("computeLibrariesPath.jar");
        Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
        ProcessorException exception = null;
        try {
            JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
        } catch (ProcessorException e) {
            exception = e;
        }
        if (exception != null) {
            Assert.assertTrue(exception.getMessage().contains("computeLibrariesPath.jar"));
        } else {
            fail("computeLibrariesPath failed for process test{tLibraryLoad},computeLibrariesPath.jar not found but no exception");
        }
    } finally {
        CommonsPlugin.setHeadless(headless);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Aggregations

ModuleNeeded (org.talend.core.model.general.ModuleNeeded)38 ArrayList (java.util.ArrayList)17 IElementParameter (org.talend.core.model.process.IElementParameter)11 HashSet (java.util.HashSet)9 File (java.io.File)8 Map (java.util.Map)8 List (java.util.List)5 Test (org.junit.Test)5 IComponent (org.talend.core.model.components.IComponent)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ElementParameter (org.talend.designer.core.model.components.ElementParameter)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 IOException (java.io.IOException)4 URL (java.net.URL)4 INode (org.talend.core.model.process.INode)4 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)3 IPath (org.eclipse.core.runtime.IPath)3 Path (org.eclipse.core.runtime.Path)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3