Search in sources :

Example 1 with RepositoryObjectTypeBuildProvider

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());
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) IMavenPomCreator(org.talend.core.runtime.repository.build.IMavenPomCreator) IProcessor(org.talend.designer.runprocess.IProcessor) Method(java.lang.reflect.Method) Item(org.talend.core.model.properties.Item) Field(java.lang.reflect.Field) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) Test(org.junit.Test)

Example 2 with RepositoryObjectTypeBuildProvider

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));
}
Also used : HashMap(java.util.HashMap) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) Test(org.junit.Test)

Example 3 with RepositoryObjectTypeBuildProvider

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));
}
Also used : HashMap(java.util.HashMap) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) Test(org.junit.Test)

Example 4 with RepositoryObjectTypeBuildProvider

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));
}
Also used : HashMap(java.util.HashMap) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) Test(org.junit.Test)

Example 5 with RepositoryObjectTypeBuildProvider

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));
}
Also used : HashMap(java.util.HashMap) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 RepositoryObjectTypeBuildProvider (org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider)22 HashMap (java.util.HashMap)20 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)7 Method (java.lang.reflect.Method)2 IFile (org.eclipse.core.resources.IFile)2 IProcess (org.talend.core.model.process.IProcess)2 Item (org.talend.core.model.properties.Item)2 IBuildExportHandler (org.talend.core.runtime.repository.build.IBuildExportHandler)2 IMavenPomCreator (org.talend.core.runtime.repository.build.IMavenPomCreator)2 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)2 IProcessor (org.talend.designer.runprocess.IProcessor)2 Field (java.lang.reflect.Field)1