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");
}
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());
}
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());
}
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);
}
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);
}
}
Aggregations