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