Search in sources :

Example 6 with AnalysisContext

use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.

the class DataExplorerTestHelper method getAnalysis.

public static Analysis getAnalysis(Indicator indicator, DbmsLanguage dbmsLanguage) {
    Analysis analysis = mock(Analysis.class);
    AnalysisContext context = mock(AnalysisContext.class);
    when(analysis.getContext()).thenReturn(context);
    DataManager dataManager = mock(DataManager.class);
    when(context.getConnection()).thenReturn(dataManager);
    // mock setEntity
    when(indicator.eClass()).thenReturn(null);
    // MOCKING STATIC METHODS
    stub(method(DbmsLanguageFactory.class, "createDbmsLanguage", DataManager.class, ExecutionLanguage.class)).toReturn(dbmsLanguage);
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 7 with AnalysisContext

use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.

the class PatternExplorerRealTest method testGetInvalidValuesStatement_3.

/**
 * Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getInvalidValuesStatement()}. when the test
 * for indicator is user define indicator
 */
@Test
public void testGetInvalidValuesStatement_3() {
    patternExplorer = new RegexPatternExplorer();
    // mock setEntity
    PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
    indicator.setIndicatorDefinition(indicatorDef);
    TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    udiTdExpression.setBody(ViewInvalidValues);
    indicatorDef.getViewInvalidValuesExpression().add(udiTdExpression);
    // create pattern parameter
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicator.setParameters(createIndicatorParameters);
    Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
    createIndicatorParameters.setDataValidDomain(createDomain);
    Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
    createDomain.getPatterns().add(createPattern);
    RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
    createPattern.getComponents().add(createPatternComponent);
    TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    createPatternComponent.setExpression(createTdExpression);
    createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createTdExpression.setBody("`su.*`");
    TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    element.setName("lname");
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    createTdTable.setName("table1");
    TableHelper.addColumn(createTdTable, element);
    Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    createCatalog.setName("catalog1");
    List<TdTable> tableList = new ArrayList<TdTable>();
    tableList.add(createTdTable);
    CatalogHelper.addTables(tableList, createCatalog);
    indicator.setAnalyzedElement(element);
    Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
    createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createIndiExpression.setBody("SELECT *  FROM `tbi`.`customer`  WHERE (customer.lname = \"sunny\")");
    indicator.setInstantiatedExpression(createIndiExpression);
    Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
    AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
    analysis.setContext(createAnalysisContext);
    DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
    createAnalysisContext.setConnection(createDatabaseConnection);
    ChartDataEntity cdEntity = new ChartDataEntity();
    cdEntity.setIndicator(indicator);
    Assert.assertTrue(patternExplorer.setAnalysis(analysis));
    patternExplorer.setEnitty(cdEntity);
    String clause = patternExplorer.getInvalidValuesStatement();
    // $NON-NLS-1$
    assertEquals("SELECT `lname` FROM `catalog1`.`table1` WHERE NOT (id>=1) ", clause);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdTable(org.talend.cwm.relational.TdTable) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) Catalog(orgomg.cwm.resource.relational.Catalog) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Example 8 with AnalysisContext

use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.

the class PatternExplorerRealTest method testGetValidRowsStatement_5.

/**
 * Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getValidRowsStatement()}. when the test for
 * indicator is user define indicator
 */
@Test
public void testGetValidRowsStatement_5() {
    patternExplorer = new RegexPatternExplorer();
    // mock setEntity
    PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
    indicator.setIndicatorDefinition(indicatorDef);
    TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    udiTdExpression.setBody(ViewValidRows);
    indicatorDef.getViewValidRowsExpression().add(udiTdExpression);
    // create pattern parameter
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicator.setParameters(createIndicatorParameters);
    Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
    createIndicatorParameters.setDataValidDomain(createDomain);
    Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
    createDomain.getPatterns().add(createPattern);
    RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
    createPattern.getComponents().add(createPatternComponent);
    TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    createPatternComponent.setExpression(createTdExpression);
    createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createTdExpression.setBody("`su.*`");
    TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    element.setName("lname");
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    createTdTable.setName("table1");
    TableHelper.addColumn(createTdTable, element);
    Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    createCatalog.setName("catalog1");
    List<TdTable> tableList = new ArrayList<TdTable>();
    tableList.add(createTdTable);
    CatalogHelper.addTables(tableList, createCatalog);
    indicator.setAnalyzedElement(element);
    Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
    createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createIndiExpression.setBody("SELECT *  FROM `tbi`.`customer`  WHERE (customer.lname = \"sunny\")");
    indicator.setInstantiatedExpression(createIndiExpression);
    Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
    AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
    analysis.setContext(createAnalysisContext);
    DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
    createAnalysisContext.setConnection(createDatabaseConnection);
    ChartDataEntity cdEntity = new ChartDataEntity();
    cdEntity.setIndicator(indicator);
    Assert.assertTrue(patternExplorer.setAnalysis(analysis));
    patternExplorer.setEnitty(cdEntity);
    String clause = patternExplorer.getValidRowsStatement();
    // $NON-NLS-1$
    assertEquals("SELECT * FROM `catalog1`.`table1` ", clause);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdTable(org.talend.cwm.relational.TdTable) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) Catalog(orgomg.cwm.resource.relational.Catalog) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Example 9 with AnalysisContext

use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.

the class FunctionFrequencyStatExplorerTest method testGetInstantiatedClause.

/**
 * Test method for {@link org.talend.dq.analysis.explore.FunctionFrequencyStatExplorer#getInstantiatedClause()}.
 */
@Test
public void testGetInstantiatedClause() {
    FunctionFrequencyStatExplorer explorer = new FunctionFrequencyStatExplorer();
    // init explorer instance
    Indicator patternFreqIndicator = IndicatorsFactory.eINSTANCE.createPatternFreqIndicator();
    ChartDataEntity entity = new ChartDataEntity(patternFreqIndicator, "entityName", "entityValue");
    entity.setKey("entityKey");
    Expression tdExpression = RelationalFactory.eINSTANCE.createTdExpression();
    // $NON-NLS-1$
    tdExpression.setLanguage("MySQL");
    tdExpression.setBody("SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9'), COUNT(*) c FROM `tbi`.`generatetable` t  GROUP BY REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9') ORDER BY c ASC LIMIT 10");
    patternFreqIndicator.setInstantiatedExpression(tdExpression);
    TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    column1.setName("columnName");
    TdSqlDataType tdSqlDataType = RelationalFactory.eINSTANCE.createTdSqlDataType();
    tdSqlDataType.setJavaDataType(Types.DATE);
    column1.setSqlDataType(tdSqlDataType);
    patternFreqIndicator.setAnalyzedElement(column1);
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisContext analysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(analysisContext);
    DatabaseConnection databaseConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
    analysisContext.setConnection(databaseConnection);
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, "MySQL");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "5.0.22-community-nt");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "'");
    explorer.setAnalysis(analysis);
    explorer.setEnitty(entity);
    String instantiatedClause = explorer.getInstantiatedClause();
    Assert.assertEquals("REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9') = 'entityKey'", instantiatedClause);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType) Indicator(org.talend.dataquality.indicators.Indicator) Test(org.junit.Test)

Example 10 with AnalysisContext

use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.

the class SummaryStastictisExplorerRealTest method testGetQueryMap.

/**
 * Test method for {@link org.talend.dq.analysis.explore.SummaryStastictisExplorer#getQueryMap()}.
 */
@Test
public void testGetQueryMap() {
    // testing code for SQL Engine here
    SummaryStastictisExplorer summaryExplorerSql = new SummaryStastictisExplorer();
    Analysis analysisReal = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisParameters analysisParametersReal = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    analysisParametersReal.setExecutionLanguage(ExecutionLanguage.SQL);
    analysisReal.setParameters(analysisParametersReal);
    AnalysisContext analysisContextReal = AnalysisFactory.eINSTANCE.createAnalysisContext();
    DataManager dataManagerReal = SoftwaredeploymentFactory.eINSTANCE.createDataManager();
    analysisContextReal.setConnection(dataManagerReal);
    analysisReal.setContext(analysisContextReal);
    summaryExplorerSql.setAnalysis(analysisReal);
    TdColumn tdColumnReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
    TdTable tdTableReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tdTableReal.setName("tableName");
    tdColumnReal.setOwner(tdTableReal);
    // $NON-NLS-1$
    tdColumnReal.setName("id");
    TdSqlDataType tdsqlReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
    // $NON-NLS-1$
    tdsqlReal.setName("Integer");
    tdColumnReal.setSqlDataType(tdsqlReal);
    // test for MeanIndicator
    MeanIndicator meanIndicator = IndicatorsFactory.eINSTANCE.createMeanIndicator();
    meanIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition meanIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    meanIndicatorDef.setName("Mean");
    meanIndicator.setIndicatorDefinition(meanIndicatorDef);
    ChartDataEntity entityReal = new ChartDataEntity();
    // $NON-NLS-1$
    entityReal.setValue("0");
    entityReal.setIndicator(meanIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    Map<String, String> queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MedianIndicator
    MedianIndicator medianIndicator = IndicatorsFactory.eINSTANCE.createMedianIndicator();
    medianIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition medianIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    medianIndicatorDef.setName("Median");
    medianIndicator.setIndicatorDefinition(medianIndicatorDef);
    entityReal.setIndicator(medianIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for IQRIndicator
    MaxValueIndicator maxValueIndicator = IndicatorsFactory.eINSTANCE.createMaxValueIndicator();
    // $NON-NLS-1$
    maxValueIndicator.setValue("80");
    IndicatorDefinition maxValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    maxValueIndicatorDef.setName("Maximum");
    maxValueIndicator.setIndicatorDefinition(maxValueIndicatorDef);
    MinValueIndicator minValueIndicator = IndicatorsFactory.eINSTANCE.createMinValueIndicator();
    // $NON-NLS-1$
    minValueIndicator.setValue("20");
    IndicatorDefinition minValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    minValueIndicatorDef.setName("Minimum");
    minValueIndicator.setIndicatorDefinition(minValueIndicatorDef);
    IQRIndicator iqrIndicator = IndicatorsFactory.eINSTANCE.createIQRIndicator();
    iqrIndicator.setUpperValue(maxValueIndicator);
    iqrIndicator.setLowerValue(minValueIndicator);
    iqrIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition iqrIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    iqrIndicatorDef.setName("Inter Quartile Range");
    iqrIndicator.setIndicatorDefinition(iqrIndicatorDef);
    entityReal.setIndicator(iqrIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 2);
    // test for LowerQuartileIndicator
    LowerQuartileIndicator lowerQuartileIndicator = IndicatorsFactory.eINSTANCE.createLowerQuartileIndicator();
    lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition lowerQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    lowerQuartileIndicatorDef.setName("Lower Quartile");
    lowerQuartileIndicator.setIndicatorDefinition(lowerQuartileIndicatorDef);
    entityReal.setIndicator(lowerQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for UpperQuartileIndicator
    UpperQuartileIndicator upperQuartileIndicator = IndicatorsFactory.eINSTANCE.createUpperQuartileIndicator();
    upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition upperQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    upperQuartileIndicatorDef.setName("Upper Quartile");
    upperQuartileIndicator.setIndicatorDefinition(upperQuartileIndicatorDef);
    entityReal.setIndicator(upperQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for RangeIndicator
    RangeIndicator rangeIndicator = IndicatorsFactory.eINSTANCE.createRangeIndicator();
    rangeIndicator.setUpperValue(maxValueIndicator);
    rangeIndicator.setLowerValue(minValueIndicator);
    rangeIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition rangeIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    rangeIndicatorDef.setName("Range");
    rangeIndicator.setIndicatorDefinition(rangeIndicatorDef);
    entityReal.setIndicator(rangeIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 2);
    // test for MinValueIndicator
    minValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(minValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for MaxValueIndicator
    maxValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(maxValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // testing code for Java Engine here
    analysisParametersReal.setExecutionLanguage(ExecutionLanguage.JAVA);
    analysisReal.setParameters(analysisParametersReal);
    summaryExplorerSql.setAnalysis(analysisReal);
    // test for MeanIndicator
    meanIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(meanIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MedianIndicator
    medianIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(medianIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for IQRIndicator
    iqrIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(iqrIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for LowerQuartileIndicator
    lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(lowerQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for UpperQuartileIndicator
    upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(upperQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for RangeIndicator
    rangeIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(rangeIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MinValueIndicator
    minValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(minValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MaxValueIndicator
    maxValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(maxValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
}
Also used : TdTable(org.talend.cwm.relational.TdTable) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) IQRIndicator(org.talend.dataquality.indicators.IQRIndicator) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) TdColumn(org.talend.cwm.relational.TdColumn) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) RangeIndicator(org.talend.dataquality.indicators.RangeIndicator) LowerQuartileIndicator(org.talend.dataquality.indicators.LowerQuartileIndicator) UpperQuartileIndicator(org.talend.dataquality.indicators.UpperQuartileIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator) Test(org.junit.Test)

Aggregations

AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)40 Analysis (org.talend.dataquality.analysis.Analysis)30 Test (org.junit.Test)17 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)15 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)13 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)13 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 TdColumn (org.talend.cwm.relational.TdColumn)11 TdTable (org.talend.cwm.relational.TdTable)11 ArrayList (java.util.ArrayList)9 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)8 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)7 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)7 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)7 DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 IPath (org.eclipse.core.runtime.IPath)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Property (org.talend.core.model.properties.Property)6 TdExpression (org.talend.cwm.relational.TdExpression)6