Search in sources :

Example 1 with RouteTestCaseBuildProvider

use of org.talend.camel.designer.build.RouteTestCaseBuildProvider in project tesb-studio-se by Talend.

the class RouteTestCaseBuildProviderTest method testCreatePomCreator.

/**
 * Test method for
 * {@link org.talend.camel.designer.build.RouteTestCaseBuildProvider#createPomCreator(java.util.Map)}.
 *
 * @throws Exception
 */
@Test
public void testCreatePomCreator() throws Exception {
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    String id = ProxyRepositoryFactory.getInstance().getNextId();
    property.setId(id);
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    itemState.setPath("");
    processItem.setState(itemState);
    processItem.setProperty(property);
    ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
    processItem.setProcess(processType);
    property.setLabel("testRoute");
    property.setVersion("0.1");
    property.setItem(processItem);
    // $NON-NLS-1$ //$NON-NLS-2$
    IComponent component = ComponentsFactoryProvider.getInstance().get("cTimer", "CAMEL");
    RouteProcess process = new RouteProcess(property);
    process.setId("routeprocess");
    INode nodeTimer = new Node(component, process);
    nodeTimer.setLabel("cTimer_1");
    MavenJavaProcessor processor = new MavenJavaProcessor(process, property, true);
    processor.setContext(process.getContextManager().getDefaultContext());
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = ResourceUtils.getProject(project);
    IPath path = new Path("poms").append("jobs").append("process").append(property.getLabel().concat("_").concat(property.getVersion()).toLowerCase()).append("temp");
    ResourceUtils.createFolder(fsProject.getFolder(path));
    path = path.append("pom.xml");
    IFile file = fsProject.getFile(path);
    String pomContent = "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + "  <modelVersion>4.0.0</modelVersion>\n" + "  <artifactId>esb.tooling.test</artifactId>\n" + "  <packaging>jar</packaging>\n" + "  <name>Test POM</name>\n" + "</project>";
    InputStream inputStream = new ByteArrayInputStream(pomContent.getBytes(StandardCharsets.UTF_8));
    file.delete(true, new NullProgressMonitor());
    file.create(inputStream, false, new NullProgressMonitor());
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(IBuildParametes.ITEM, processItem);
    parameters.put(IBuildPomCreatorParameters.PROCESSOR, processor);
    parameters.put(IBuildPomCreatorParameters.FILE_POM, file);
    parameters.put(IBuildPomCreatorParameters.OVERWRITE_POM, Boolean.TRUE);
    IMavenPomCreator creator = new RouteTestCaseBuildProvider().createPomCreator(parameters);
    creator.create(new NullProgressMonitor());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RouteTestCaseBuildProvider(org.talend.camel.designer.build.RouteTestCaseBuildProvider) INode(org.talend.core.model.process.INode) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IComponent(org.talend.core.model.components.IComponent) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IMavenPomCreator(org.talend.core.runtime.repository.build.IMavenPomCreator) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) MavenJavaProcessor(org.talend.designer.runprocess.maven.MavenJavaProcessor) ProcessItem(org.talend.core.model.properties.ProcessItem) ByteArrayInputStream(java.io.ByteArrayInputStream) ItemState(org.talend.core.model.properties.ItemState) RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Test (org.junit.Test)1 RouteTestCaseBuildProvider (org.talend.camel.designer.build.RouteTestCaseBuildProvider)1 RouteProcess (org.talend.camel.designer.ui.editor.RouteProcess)1 IComponent (org.talend.core.model.components.IComponent)1 Project (org.talend.core.model.general.Project)1 INode (org.talend.core.model.process.INode)1 ItemState (org.talend.core.model.properties.ItemState)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Property (org.talend.core.model.properties.Property)1 IMavenPomCreator (org.talend.core.runtime.repository.build.IMavenPomCreator)1 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1