Search in sources :

Example 26 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class AnalysisExecutorHelperTest method testCheckIndicatorWithOutDependencyFiles.

@Test
public void testCheckIndicatorWithOutDependencyFiles() {
    // Load analysis item/property model from test file.
    // $NON-NLS-1$
    String anaPropertyFile = "/data/builtin/indicator_without_dep/TDQ_Data_Profiling/Analyses/patternMatchAna_0.1.properties";
    Resource anaPropertyResource = getPlatformResource(anaPropertyFile);
    Analysis ana = null;
    Property anaProperty = null;
    while (anaPropertyResource.getAllContents().hasNext()) {
        EObject eobj = anaPropertyResource.getAllContents().next();
        if (eobj instanceof Property) {
            anaProperty = (Property) eobj;
            ana = ((TDQAnalysisItem) anaProperty.getItem()).getAnalysis();
            break;
        }
    }
    if (ana == null) {
        Assert.fail("The analysis is null!");
    }
    if (ana.getResults() == null) {
        Assert.fail("The result of analysis is null!");
    }
    if (ana.getResults().getIndicators() == null) {
        Assert.fail("The indicators of analysis is null!");
    }
    for (Indicator indicator : ana.getResults().getIndicators()) {
        if (!(indicator instanceof PatternMatchingIndicator)) {
            // Check system indicator and UDI
            assertTrue(indicator.getIndicatorDefinition().getName() != null);
            assertTrue(indicator.getBuiltInIndicatorDefinition() != null);
            assertTrue(indicator.getBuiltInIndicatorDefinition() == indicator.getIndicatorDefinition());
        }
    }
    ReturnCode rc = AnalysisExecutorHelper.check(ana);
    assertTrue(rc.isOk());
    for (Indicator indicator : ana.getResults().getIndicators()) {
        if (!(indicator instanceof PatternMatchingIndicator)) {
            // Check system indicator and UDI
            assertTrue(indicator.getIndicatorDefinition().getName() != null);
            assertTrue(indicator.getBuiltInIndicatorDefinition() != null);
            assertTrue(indicator.getBuiltInIndicatorDefinition() == indicator.getIndicatorDefinition());
        }
    }
}
Also used : PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) Property(org.talend.core.model.properties.Property) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) Test(org.junit.Test)

Example 27 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class AnalysisExecutorHelperTest method testCheckIndicatorWithOutDependencyFilesAndBuiltIn.

@Test
public void testCheckIndicatorWithOutDependencyFilesAndBuiltIn() {
    // Load analysis item/property model from test file.
    // $NON-NLS-1$
    String anaPropertyFile = "/data/builtin/indicator_without_dep_builtin/TDQ_Data_Profiling/Analyses/patternMatchAna_0.1.properties";
    Resource anaPropertyResource = getPlatformResource(anaPropertyFile);
    Analysis ana = null;
    Property anaProperty = null;
    while (anaPropertyResource.getAllContents().hasNext()) {
        EObject eobj = anaPropertyResource.getAllContents().next();
        if (eobj instanceof Property) {
            anaProperty = (Property) eobj;
            ana = ((TDQAnalysisItem) anaProperty.getItem()).getAnalysis();
            break;
        }
    }
    if (ana == null) {
        Assert.fail("The analysis is null!");
    }
    if (ana.getResults() == null) {
        Assert.fail("The result of analysis is null!");
    }
    if (ana.getResults().getIndicators() == null) {
        Assert.fail("The indicators of analysis is null!");
    }
    for (Indicator indicator : ana.getResults().getIndicators()) {
        if (!(indicator instanceof PatternMatchingIndicator)) {
            // Check system indicator and UDI
            assertTrue(indicator.getIndicatorDefinition().getName() == null);
            assertTrue(indicator.getBuiltInIndicatorDefinition() == null);
        }
    }
    ReturnCode rc = AnalysisExecutorHelper.check(ana);
    assertFalse(rc.isOk());
}
Also used : PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) Property(org.talend.core.model.properties.Property) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) Test(org.junit.Test)

Example 28 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class InidcatorUnitTest method testIsExsitingFormCase1.

/**
 * Test method for {@link org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#isExsitingForm()}.
 *
 * test case 1:ColumnIndicatorUnit
 */
@Test
public void testIsExsitingFormCase1() {
    Indicator indicator = IndicatorsFactory.eINSTANCE.createIndicator();
    ModelElementIndicator modelElementIndicator = UnitTestBuildHelper.createModelElementIndicator();
    // Count UDI case
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    createIndicatorDefinition.getCategories().add(DefinitionHandler.getInstance().getUserDefinedCountIndicatorCategory());
    indicator.setIndicatorDefinition(createIndicatorDefinition);
    ColumnIndicatorUnit colUnit = new ColumnIndicatorUnit(IndicatorEnum.UserDefinedIndicatorEnum, indicator, modelElementIndicator);
    boolean exsitingForm = colUnit.isExsitingForm();
    // TDQ-10557: Allow set threshold option on UDIs
    Assert.assertEquals("indicator " + IndicatorEnum.UserDefinedIndicatorEnum.getLabel() + " User Defined Count exists Form enum", true, exsitingForm);
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Test(org.junit.Test)

Example 29 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class IndicatorHelperTest method testGetPatternName.

/**
 * Test method for get pattern name based on indicator.
 */
@Test
public void testGetPatternName() {
    Indicator indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    IndicatorParameters parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    Domain validData = DomainFactory.eINSTANCE.createDomain();
    Pattern pattern = PatternFactory.eINSTANCE.createPattern();
    // $NON-NLS-1$
    String pn = "Blank Text";
    pattern.setName(pn);
    validData.getPatterns().add(pattern);
    parameters.setDataValidDomain(validData);
    indicator.setParameters(parameters);
    String patternName = IndicatorHelper.getPatternName(indicator);
    assert (patternName.equals(pn));
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) Domain(org.talend.dataquality.domain.Domain) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) Test(org.junit.Test)

Example 30 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class IndicatorHelperTest method testGetNullCountIndicator1.

/**
 * Test method for
 * {@link org.talend.dataquality.helpers.IndicatorHelper#getNullCountIndicator(orgomg.cwm.objectmodel.core.ModelElement, java.util.Map)}
 * . get NullCountIndicator
 */
@Test
public void testGetNullCountIndicator1() {
    // TdColumn
    TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
    // ~
    // Indicator
    Indicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
    Indicator nullCountIndicator = IndicatorsFactory.eINSTANCE.createNullCountIndicator();
    // ~
    // List
    List<Indicator> list = new ArrayList<Indicator>();
    list.add(rowCountIndicator);
    list.add(nullCountIndicator);
    // ~
    // Map
    Map<ModelElement, List<Indicator>> elementToIndicator = new HashMap<ModelElement, List<Indicator>>();
    elementToIndicator.put(column1, list);
    // ~
    NullCountIndicator nullCountIndicator2 = IndicatorHelper.getNullCountIndicator(column1, elementToIndicator);
    assert (nullCountIndicator2 != null);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Test(org.junit.Test)

Aggregations

Indicator (org.talend.dataquality.indicators.Indicator)178 ArrayList (java.util.ArrayList)58 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)40 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)31 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)31 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)28 Analysis (org.talend.dataquality.analysis.Analysis)27 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)27 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)27 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)26 ReturnCode (org.talend.utils.sugars.ReturnCode)25 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)24 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)24 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)23 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)22 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)22 TdColumn (org.talend.cwm.relational.TdColumn)20 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)18 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)17 Test (org.junit.Test)16