@Test public void testCustomonnectorMigrationWithGetterCustom() throws Exception { final URL url = TestCustomConnectorMigrationUseCase.class.getResource("fab--1.0.bar"); final File migratedProc = BarImporterTestUtil.migrateBar(url); assertNotNull("Fail to migrate bar file", migratedProc); assertNotNull("Fail to migrate bar file", migratedProc.exists()); final Resource resource = BarImporterTestUtil.assertIsLoadable(migratedProc); final MainProcess mainProc = BarImporterTestUtil.getMainProcess(resource); final ConnectorDefRepositoryStore defStore = (ConnectorDefRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class); assertNotNull(defStore.getDefinition("fabulous_connector", "1.0.0")); final ConnectorImplRepositoryStore implStore = (ConnectorImplRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorImplRepositoryStore.class); ConnectorImplementation implementation = implStore.getImplementation("fabulous_connector-impl", "1.0.0"); assertNotNull(implementation); final ConnectorSourceRepositoryStore sourceStore = (ConnectorSourceRepositoryStore) RepositoryManager.getInstance() .getRepositoryStore(ConnectorSourceRepositoryStore.class); assertNotNull(sourceStore.getChild(implementation.getImplementationClassname())); final List<Connector> connectors = ModelHelper.getAllItemsOfType(mainProc, ProcessPackage.Literals.CONNECTOR); assertEquals("Invalid number of connector", 1, connectors.size()); }
protected IStatus addImplementationJar( ConnectorImplementation implementation, IFolder classpathFolder, SourceRepositoryStore sourceStore, IRepositoryStore implStore, List<IResource> resourcesToExport) throws CoreException, InvocationTargetException, InterruptedException { final String connectorJarName = NamingUtils.toConnectorImplementationFilename( implementation.getImplementationId(), implementation.getImplementationVersion(), false) + ".jar"; final IFile jarFile = classpathFolder.getFile(Path.fromOSString(connectorJarName)); String qualifiedClassName = impl.getImplementationClassname(); String packageName = ""; if (qualifiedClassName.indexOf(".") != -1) { packageName = qualifiedClassName.substring(0, qualifiedClassName.lastIndexOf(".")); } final PackageFileStore file = (PackageFileStore) sourceStore.getChild(packageName); if (file != null) { file.exportAsJar(jarFile.getLocation().toFile().getAbsolutePath(), false); if (includeSources) { IFolder srcFolder = implStore.getResource().getFolder(SRC_DIR); if (srcFolder.exists()) { srcFolder.delete(true, Repository.NULL_PROGRESS_MONITOR); } srcFolder.create(true, true, Repository.NULL_PROGRESS_MONITOR); cleanAfterExport.add(srcFolder); IPath path = file.getResource() .getFullPath() .makeRelativeTo(sourceStore.getResource().getFullPath()); IFolder newFolder = srcFolder.getFolder(path); newFolder.getLocation().toFile().getParentFile().mkdirs(); srcFolder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR); file.getResource().copy(newFolder.getFullPath(), true, Repository.NULL_PROGRESS_MONITOR); resourcesToExport.add(srcFolder); } } return Status.OK_STATUS; }