use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class DiDemoImportTest method testDiDemoJobItemsComplete.
@Test
public void testDiDemoJobItemsComplete() throws Exception {
// test the job items under DI_Demo.zip
Assert.assertTrue(diResManager instanceof FileResourcesUnityManager);
Iterator path = diResManager.getPaths().iterator();
String firstFilePath = ((Path) path.next()).toPortableString();
String tempFolderPath = firstFilePath.substring(0, firstFilePath.indexOf(TEMP_FOLDER_SUFFIEX) + TEMP_FOLDER_SUFFIEX.length());
Assert.assertTrue(new File(tempFolderPath).exists());
String rootPath = tempFolderPath + File.separator + demoName;
Assert.assertTrue(new File(rootPath).exists());
File tempJobsFolder = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
Assert.assertTrue(currentJobItemsSize > 0);
// items in the DI_Demo.zip,there only has one item with two versions,the item is tAddCRC,maybe need only
// keep one version later for this item
Assert.assertEquals(demoJobItemFiles.size() - 1, currentJobItemsSize);
// test the context items under DI_Demo.zip
int currentContextItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.CONTEXT).size();
File tempContextItemsFolder = new File(rootPath + File.separator + contextItemPath);
List<File> demoContextItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempContextItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoContextItemsFiles.size() > 0);
Assert.assertTrue(currentContextItemsSize > 0);
Assert.assertEquals(demoContextItemsFiles.size(), currentContextItemsSize);
// test the metadata items under DI_Demo.zip
int currentConnectionItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA).size();
File tempConnItemsFolder = new File(rootPath + File.separator + connectionItemPath);
List<File> demoConItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempConnItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoConItemsFiles.size() > 0);
Assert.assertTrue(currentConnectionItemsSize > 0);
Assert.assertEquals(demoConItemsFiles.size(), currentConnectionItemsSize);
// test the routine items under DI_Demo.zip
doRoutinesItemsTest(rootPath);
// test the business process items under DI_Demo.zip
int currentBusinessItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.BUSINESS_PROCESS).size();
File tempBusinessItemsFolder = new File(rootPath + File.separator + bussniessProcessPath);
List<File> demoBusinessItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempBusinessItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoBusinessItemsFiles.size() > 0);
Assert.assertTrue(currentBusinessItemsSize > 0);
Assert.assertEquals(demoBusinessItemsFiles.size(), currentBusinessItemsSize);
// test the documention items under DI_Demo.zip
int currentDocItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.DOCUMENTATION).size();
File tempDocItemsFolder = new File(rootPath + File.separator + documentionPath);
List<File> demoDocItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempDocItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoDocItemsFiles.size() > 0);
Assert.assertTrue(currentDocItemsSize > 0);
Assert.assertEquals(demoDocItemsFiles.size(), currentDocItemsSize);
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class BigdataCeImportTest method testBdCeDemoComplete.
@Test
public void testBdCeDemoComplete() throws Exception {
if (currentDemo == null) {
// maybe license problem, the demo plugin is not loaded.
return;
}
Assert.assertTrue(ceResManager instanceof FileResourcesUnityManager);
Iterator path = ceResManager.getPaths().iterator();
String firstFilePath = ((Path) path.next()).toPortableString();
String ceDemoName = demoName.substring(0, demoName.indexOf("_"));
String tempFolderPath = firstFilePath.substring(0, firstFilePath.indexOf(TEMP_FOLDER_SUFFIEX) + TEMP_FOLDER_SUFFIEX.length());
Assert.assertTrue(new File(tempFolderPath).exists());
String rootPath = tempFolderPath + File.separator + ceDemoName;
Assert.assertTrue(new File(rootPath).exists());
// test the job items under BigDataDemo_ce.zip
File tempJobsFolder = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
Assert.assertTrue(currentJobItemsSize > 0);
Assert.assertEquals(demoJobItemFiles.size(), currentJobItemsSize);
// test the context items under BigDataDemo_ce.zip
int currentContextItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.CONTEXT).size();
Assert.assertTrue(currentContextItemsSize > 0);
File tempContextItemsFolder = new File(rootPath + File.separator + contextItemPath);
List<File> demoContextItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempContextItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoContextItemsFiles.size() > 0);
Assert.assertEquals(demoContextItemsFiles.size(), currentContextItemsSize);
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManager.
public static ResourcesManager getResourceManager(DemoProjectBean checkedProjectBean) {
ResourcesManager resManager = null;
try {
Bundle bundle = Platform.getBundle(checkedProjectBean.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(checkedProjectBean.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManager;
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class BuildJobHandlerTest method setUp.
@Before
public void setUp() throws Exception {
// Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
bridgeProject = ReponsitoryContextBridge.getProject();
ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
ImportExportHandlersManager importManager = new ImportExportHandlersManager();
// job with tdm and tdq component.
URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"), new Path("/resources/testBuildJob.zip"), null);
if (testJobURL != null) {
testJobURL = FileLocator.toFileURL(testJobURL);
}
File srcFile = new File(testJobURL.getFile());
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
ResourcesManager resManager = fileUnityManager.doUnify();
List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
assertTrue(projectRecords.size() > 0);
importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion("_bWyBUAYbEeapTZ0aKwL_YA");
Item item = obj.getProperty().getItem();
assertTrue(item instanceof ProcessItem);
processItem = (ProcessItem) item;
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class MdmEeDemoImportTest method testMdmEeDemoImportComplete.
@Test
public void testMdmEeDemoImportComplete() throws Exception {
Assert.assertTrue(mdmResEeManager instanceof FileResourcesUnityManager);
Iterator pathes = mdmResEeManager.getPaths().iterator();
IPath projectPath = null;
while (pathes.hasNext()) {
IPath p = ((Path) pathes.next());
if (p.lastSegment().equals(FileConstants.LOCAL_PROJECT_FILENAME)) {
projectPath = p;
break;
}
}
Assert.assertNotNull("Can't find the talend.project, so it's invalid demo", projectPath);
final File talendProjectFile = projectPath.toFile();
Assert.assertTrue(talendProjectFile.exists());
String rootPath = talendProjectFile.getParentFile().toString();
// test the job items under MDM_EE_Demo.zip
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
File tempJobsFolderForDemo = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolderForDemo, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
Assert.assertTrue(currentJobItemsSize > 0);
Assert.assertEquals(demoJobItemFiles.size(), currentJobItemsSize);
// test the context items under MDM_EE_Demo.zip
int currentContextItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.CONTEXT).size();
Assert.assertTrue(currentContextItemsSize > 0);
File tempContextItemsFolder = new File(rootPath + File.separator + contextItemPath);
List<File> demoContextItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempContextItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoContextItemsFiles.size() > 0);
Assert.assertEquals(demoContextItemsFiles.size(), currentContextItemsSize);
// test the metadata items under MDM_EE_Demo.zip
int currentConnectionItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA).size();
Assert.assertTrue(currentConnectionItemsSize == 0);
File tempConnItemsFolder = new File(rootPath + File.separator + connectionItemPath);
List<File> demoConItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempConnItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoConItemsFiles.size() > 0);
// 1.test the item under MDM/datamodel
int currentDmItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.DataModel")).size();
Assert.assertTrue(currentDmItemsSize > 0);
File tempDmItemsFolder = new File(rootPath + File.separator + mdmDataModelath);
List<File> demoDmItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempDmItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoDmItemsFiles.size() > 0);
Assert.assertEquals(demoDmItemsFiles.size(), currentDmItemsSize);
// 2.test the item under MDM/resource
int currentResItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.Resource")).size();
Assert.assertTrue(currentResItemsSize > 0);
File tempResItemsFolder = new File(rootPath + File.separator + mdmResourcePath);
List<File> demoResItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempResItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoResItemsFiles.size() > 0);
Assert.assertEquals(demoResItemsFiles.size(), currentResItemsSize);
// 3.test the item under MDM/role
int currentRoleItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.Role")).size();
Assert.assertTrue(currentRoleItemsSize > 0);
File tempRoleItemsFolder = new File(rootPath + File.separator + mdmRolePath);
List<File> demoRoleItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRoleItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoRoleItemsFiles.size() > 0);
Assert.assertEquals(demoRoleItemsFiles.size(), currentRoleItemsSize);
// 3.test the item under MDM/routingrule
int currentRoutineRoletemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.RoutingRule")).size();
Assert.assertTrue(currentRoutineRoletemsSize > 0);
File tempRoutineRoletemsFolder = new File(rootPath + File.separator + mdmRoutingrulePath);
List<File> demoRoutineRoleItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRoutineRoletemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoRoutineRoleItemsFiles.size() > 0);
Assert.assertEquals(demoRoutineRoleItemsFiles.size(), currentRoutineRoletemsSize);
// 4.test the item under MDM/transformerV2
int currentTransItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.TransformerV2")).size();
Assert.assertTrue(currentTransItemsSize > 0);
File tempTransItemsFolder = new File(rootPath + File.separator + mdmTransformerV2Path);
List<File> demoTransItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempTransItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoTransItemsFiles.size() > 0);
Assert.assertEquals(demoTransItemsFiles.size(), currentTransItemsSize);
// 5.test the item under MDM/view
int currentViewItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.View")).size();
Assert.assertTrue(currentViewItemsSize > 0);
File tempViewItemsFolder = new File(rootPath + File.separator + mdmViewPath);
List<File> demoViewtemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempViewItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoViewtemsFiles.size() > 0);
Assert.assertEquals(demoViewtemsFiles.size(), currentViewItemsSize);
// 6.test the item under MDM/workflow
int currentWorkflowItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "MDM.Workflow")).size();
Assert.assertTrue(currentWorkflowItemsSize > 0);
File tempWorkflowItemsFolder = new File(rootPath + File.separator + mdmWorkflowPath);
List<File> demoWorkflowtemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempWorkflowItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoWorkflowtemsFiles.size() > 0);
Assert.assertEquals(demoWorkflowtemsFiles.size(), currentWorkflowItemsSize);
}
Aggregations