use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class RepositoryNodeHelperRealTest method testCreateMysqlTableRepositoryNode.
/**
* Test method for
* {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
* mysql case find table node
*/
@Test
public void testCreateMysqlTableRepositoryNode() {
// $NON-NLS-1$
DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
// $NON-NLS-1$
Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
// $NON-NLS-1$
TdTable addTable = this.addTable(addCatalog, "table1");
try {
ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addTable);
if (createRepositoryNode != null) {
IRepositoryViewObject object = createRepositoryNode.getObject();
Assert.assertTrue(createRepositoryNode instanceof DBTableRepNode);
Assert.assertTrue(object != null);
Assert.assertTrue(object instanceof TdTableRepositoryObject);
Assert.assertTrue(object.getId().equals(addTable.getName()));
Assert.assertTrue(object.getLabel().equals(addTable.getName()));
Assert.assertTrue(object.getRepositoryNode() != null);
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent() != null);
}
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class ExportConnectionToTOSActionRealTest method testRuncase1.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.action.actions.ExportConnectionToTOSAction#run()}.
*
* @throws PersistenceException
*
* case1: create new connection from catalog case
*/
@Test
public void testRuncase1() throws PersistenceException {
// connectionNode
DatabaseConnectionItem createOldConnectionItem = createConnectionItem("ExportConnectionToTOSActionRealTest1", null, false, // $NON-NLS-1$
true);
Assert.assertTrue(createOldConnectionItem.getConnection() != null);
Assert.assertTrue(createOldConnectionItem.getConnection().eResource() != null);
Assert.assertTrue(!createOldConnectionItem.getConnection().eIsProxy());
IRepositoryViewObject createdByUs = factory.getLastVersion(createOldConnectionItem.getProperty().getId());
Assert.assertTrue(createdByUs != null);
// $NON-NLS-1$
Assert.assertTrue("ExportConnectionToTOSActionRealTest1".equals(createdByUs.getLabel()));
initCatalogList(createOldConnectionItem);
// ~connectionNode
List<Package> packageList = new ArrayList<Package>();
packageList.add(catalog1);
createAction = PowerMockito.spy(new ExportConnectionToTOSAction(packageList));
PowerMockito.doNothing().when(createAction).openSuccessInformation();
PowerMockito.doNothing().when(createAction).refreshViewerAndNode();
createAction.run();
IRepositoryViewObject createByAction = getNewCreatedConnectionByName(createOldConnectionItem.getConnection().getLabel() + "_" + // $NON-NLS-1$
catalog1.getName());
Assert.assertTrue(createByAction != null);
DatabaseConnectionItem item = (DatabaseConnectionItem) createByAction.getProperty().getItem();
Connection newConnection = item.getConnection();
Catalog exportedCatalog = CatalogHelper.getCatalog(newConnection, catalog1.getName());
Assert.assertTrue(newConnection.getLabel().equals(// $NON-NLS-1$
createOldConnectionItem.getConnection().getLabel() + "_" + catalog1.getName()));
Assert.assertTrue(exportedCatalog != null);
Assert.assertTrue(exportedCatalog != catalog1);
factory.deleteObjectPhysical(createByAction);
factory.deleteObjectPhysical(createdByUs);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class DBConnectionDuplicateHandleTest method addDatapackage.
private Catalog addDatapackage(String packageName, DatabaseConnectionItem connItem) throws PersistenceException {
Connection connection = connItem.getConnection();
Catalog createCatalog = CatalogHelper.createCatalog(packageName);
ConnectionHelper.addCatalog(createCatalog, connection);
factory.save(connItem, null);
return createCatalog;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method createCatalog.
/**
* DOC talend Comment method "createCatalog".
*
* @param catalogName
*/
private Catalog createCatalog(String catalogName) {
Connection connection = createDatabaseConnectionItem.getConnection();
Catalog createCatalog = CatalogHelper.createCatalog(catalogName);
ConnectionHelper.addCatalog(createCatalog, connection);
return createCatalog;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase6.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
* . case6 :input parameter is DBTableFolderRepNode
*/
@Test
public void testGetConnectionCase6() {
// create FileConnection
// connection
IRepositoryViewObject lastVersion = null;
String propertyID = createConnectionItem(connectionName, null, null);
// $NON-NLS-1$
Catalog createCatalog = createCatalog("catalog1");
try {
lastVersion = factory.getLastVersion(propertyID);
lastVersion = new MetadataCatalogRepositoryObject(lastVersion, createCatalog);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
// ~connection data
// ~FileConnection
// create DFColumnFolderRepNode
Assert.assertFalse(lastVersion == null);
RepositoryNode dbCatalogRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(lastVersion, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
DBTableFolderRepNode dbTableFolderRepNode = new DBTableFolderRepNode(null, dbCatalogRepNode, null, null);
// ~DFColumnFolderRepNode
AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
Connection connection = provider.getConnection(dbTableFolderRepNode);
Assert.assertTrue(connection != null);
}
Aggregations