use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class AbstractSchemaEvaluatorTest method testAddToConnectionIndicator2Parameters.
@Test
public /**
* No mock. using java reflect mechanism to set private variable.
* @throws SQLException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws NoSuchFieldException
* @throws SecurityException
* @throws NoSuchMethodException
* @throws IllegalArgumentException
* @throws InvocationTargetException
*/
void testAddToConnectionIndicator2Parameters() throws SQLException, InstantiationException, IllegalAccessException, NoSuchFieldException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
//
Connection dataProvider = ConnectionFactory.eINSTANCE.createConnection();
ConnectionIndicator connectionIndicator = SchemaFactory.eINSTANCE.createConnectionIndicator();
List<Indicator> indicators = new ArrayList<Indicator>();
indicators.add(connectionIndicator);
Class<ConnectionEvaluator> connEval = ConnectionEvaluator.class;
ConnectionEvaluator instance = connEval.newInstance();
// $NON-NLS-1$
Field field = connEval.getDeclaredField("dataProvider");
field.setAccessible(true);
field.set(instance, dataProvider);
// $NON-NLS-1$
Field field2 = connEval.getDeclaredField("elementIndics");
field2.setAccessible(true);
field2.set(instance, indicators);
SchemaIndicator schemaIndic1 = SchemaFactory.eINSTANCE.createSchemaIndicator();
schemaIndic1.setTableCount(3);
schemaIndic1.setViewCount(1);
schemaIndic1.setTableRowCount(100L);
SchemaIndicator schemaIndic2 = SchemaFactory.eINSTANCE.createSchemaIndicator();
schemaIndic2.setTableCount(2);
schemaIndic2.setViewCount(2);
schemaIndic2.setTableRowCount(95L);
CatalogIndicator catalogIndic = SchemaFactory.eINSTANCE.createCatalogIndicator();
catalogIndic.setSchemaCount(2);
for (int i = 0; i < 2; i++) {
if (i == 0) {
instance.addToConnectionIndicator(catalogIndic, schemaIndic1);
} else {
instance.addToConnectionIndicator(catalogIndic, schemaIndic2);
}
}
assertEquals(connectionIndicator.getCatalogCount(), 1);
assertEquals(connectionIndicator.getSchemaCount(), 2);
assertEquals(connectionIndicator.getTableCount(), 5);
assertEquals(connectionIndicator.getViewCount(), 3);
assertEquals(connectionIndicator.getTableRowCount(), 195);
}
use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionAnalysisWizard method initCWMResourceBuilder.
@Override
public ModelElement initCWMResourceBuilder() {
Analysis analysis = (Analysis) super.initCWMResourceBuilder();
if (getAnalysisBuilder() != null) {
IRepositoryNode connectionRepNode = getParameter().getConnectionRepNode();
ConnectionItem item = (ConnectionItem) connectionRepNode.getObject().getProperty().getItem();
Connection tdProvider = item.getConnection();
getAnalysisBuilder().setAnalysisConnection(tdProvider);
ConnectionIndicator indicator = SchemaFactory.eINSTANCE.createConnectionIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
indicator.setAnalyzedElement(tdProvider);
List<Schema> tdSchemas = ConnectionHelper.getSchema(tdProvider);
if (tdSchemas.size() != 0) {
addSchemaIndicator(tdSchemas, indicator);
}
List<Catalog> tdCatalogs = ConnectionHelper.getCatalogs(tdProvider);
for (Catalog tdCatalog : tdCatalogs) {
CatalogIndicator createCatalogIndicator = SchemaFactory.eINSTANCE.createCatalogIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(createCatalogIndicator);
createCatalogIndicator.setAnalyzedElement(tdCatalog);
// MOD xqliu 2009-11-30 bug 9114
indicator.addCatalogIndicator(createCatalogIndicator);
// ~
addSchemaIndicator(CatalogHelper.getSchemas(tdCatalog), indicator);
}
getAnalysisBuilder().addElementToAnalyze(tdProvider, indicator);
}
return analysis;
}
Aggregations