use of org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createPomCreator.
@Test
public void test_createPomCreator() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
Item jobItem = createJobItem();
final IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Assert.assertNotNull(designerCoreService);
final IProcess processFromItem = designerCoreService.getProcessFromItem(jobItem);
IProcessor processor = ProcessorUtilities.getProcessor(processFromItem, jobItem.getProperty());
final Class<? extends IProcessor> processorClazz = processor.getClass();
Assert.assertEquals("org.talend.designer.runprocess.maven.MavenJavaProcessor", processorClazz.getName());
processor.setContext(processor.getProcess().getContextManager().getDefaultContext());
parameters.put(IBuildPomCreatorParameters.PROCESSOR, processor);
final Method getPomFileMethod = processorClazz.getDeclaredMethod("getPomFile");
getPomFileMethod.setAccessible(true);
final Object getPomFile = getPomFileMethod.invoke(processor);
Assert.assertTrue(getPomFile instanceof IFile);
IFile pomFile = (IFile) getPomFile;
parameters.put(IBuildPomCreatorParameters.FILE_POM, pomFile);
final Method getAssemblyFileMethod = processorClazz.getDeclaredMethod("getAssemblyFile");
getAssemblyFileMethod.setAccessible(true);
final Object getAssemblyFile = getAssemblyFileMethod.invoke(processor);
Assert.assertTrue(getPomFile instanceof IFile);
IFile assemblyFile = (IFile) getAssemblyFile;
parameters.put(IBuildPomCreatorParameters.FILE_ASSEMBLY, assemblyFile);
// before set classpath, must do initJobClasspath
final Method initJobClasspathMethod = processorClazz.getDeclaredMethod("initJobClasspath");
initJobClasspathMethod.setAccessible(true);
initJobClasspathMethod.invoke(processor);
final Field windowsClasspathField = processorClazz.getDeclaredField("windowsClasspath");
windowsClasspathField.setAccessible(true);
parameters.put(IBuildPomCreatorParameters.CP_WIN, windowsClasspathField.get(processor));
final Field unixClasspathField = processorClazz.getDeclaredField("unixClasspath");
unixClasspathField.setAccessible(true);
parameters.put(IBuildPomCreatorParameters.CP_LINUX, unixClasspathField.get(processor));
parameters.put(IBuildParametes.ITEM, processor.getProperty().getItem());
final Map<String, Object> arguments = processor.getArguments();
parameters.put(IBuildPomCreatorParameters.ARGUMENTS_MAP, arguments);
parameters.put(IBuildPomCreatorParameters.OVERWRITE_POM, true);
// create pom and assembly
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
final IMavenPomCreator pomCreator = provider.createPomCreator(parameters);
Assert.assertNotNull("Create the pom creator failure", pomCreator);
Assert.assertEquals(CreateMavenJobPom.class, pomCreator.getClass());
pomCreator.create(null);
pomFile.getParent().refreshLocal(IResource.DEPTH_ONE, null);
Assert.assertTrue("the pom file " + pomFile.getName() + " is not created ", pomFile.exists());
assemblyFile.getParent().refreshLocal(IResource.DEPTH_ONE, null);
Assert.assertTrue("the assembly file " + assemblyFile.getName() + " is not created ", assemblyFile.exists());
}
use of org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createBuildExportHandler_nullVersion.
@Test
public void test_createBuildExportHandler_nullVersion() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(IBuildParametes.ITEM, PropertiesFactory.eINSTANCE.createProcessItem());
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
Assert.assertNull(provider.createBuildExportHandler(parameters));
}
use of org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createPomCreator_nonAssemblyFile.
@Test
public void test_createPomCreator_nonAssemblyFile() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(IBuildPomCreatorParameters.PROCESSOR, new TestProcessor());
ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
parameters.put(IBuildPomCreatorParameters.FILE_POM, talendProcessJavaProject.getProject().getFile("pom_abc.xml"));
parameters.put(IBuildParametes.ITEM, PropertiesFactory.eINSTANCE.createProcessItem());
parameters.put(IBuildPomCreatorParameters.FILE_ASSEMBLY, new Object());
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
Assert.assertNull(provider.createPomCreator(parameters));
}
use of org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createBuildExportHandler_nonItem.
@Test
public void test_createBuildExportHandler_nonItem() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(IBuildParametes.ITEM, "fakeValue");
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
Assert.assertNull(provider.createBuildExportHandler(parameters));
parameters.put(IBuildParametes.ITEM, PropertiesFactory.eINSTANCE.createJobletProcessItem());
Assert.assertNull(provider.createBuildExportHandler(parameters));
}
use of org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createBuildExportHandler_nonChoiceMap.
@Test
public void test_createBuildExportHandler_nonChoiceMap() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(IBuildParametes.ITEM, PropertiesFactory.eINSTANCE.createProcessItem());
parameters.put(IBuildParametes.VERSION, "0.1");
parameters.put(IBuildJobParameters.CONTEXT_GROUP, "Dev");
parameters.put(IBuildJobParameters.CHOICE_OPTION, "xxx");
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
Assert.assertNull(provider.createBuildExportHandler(parameters));
}
Aggregations