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