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());
}
}
}
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());
}
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);
}
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));
}
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);
}
Aggregations