use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class ColumnSetAnalysisDetailsPage method refreshIndicatorsSection.
/**
* refresh the Indicators Section.
*/
public void refreshIndicatorsSection() {
// when there have pattern, show allmatchindicator
ModelElementIndicator[] modelElementIndicator = treeViewer.getModelElementIndicator();
if (modelElementIndicator != null) {
for (ModelElementIndicator modelElementInd : modelElementIndicator) {
Indicator[] inds = modelElementInd.getPatternIndicators();
for (Indicator ind : inds) {
if (ind instanceof RegexpMatchingIndicator) {
indicatorsViewer.setInput(simpleStatIndicator, allMatchIndicator);
return;
}
}
}
}
indicatorsViewer.setInput(simpleStatIndicator);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class PatternStatisticeStateUtilTest method testGetUnitValueCase1.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
* .
* case1:normal RegexpMatchingIndicator case
*/
@Test
public void testGetUnitValueCase1() {
Object pMatchExt = null;
RegexpMatchingIndicator regexpMatchingIndicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
regexpMatchingIndicator.setComputed(true);
regexpMatchingIndicator.setMatchingValueCount(40l);
regexpMatchingIndicator.setNotMatchingValueCount(50l);
PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(regexpMatchingIndicator, pMatchExt);
// $NON-NLS-1$
Assert.assertEquals("Matching count value shoud be 40l", 40l, unitValue.getMatchingValueCount());
// $NON-NLS-1$
Assert.assertEquals("Not matching count value shoud be 50l", 50l, unitValue.getNotMatchingValueCount());
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class RegexpMatchingIndicatorImplTest method testGetRegexFail2DomainIsNull.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
*/
@Test
public void testGetRegexFail2DomainIsNull() {
// RegexpMatchingIndicator
RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// ~RegexpMatchingIndicator
// IndicatorParameters
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// ~IndicatorParameters
createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
// call getRegex()
String regexResult = createRegexpMatchingIndicator.getRegex();
// ~call getRegex()
Assert.assertTrue(regexResult == null);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class RegexpMatchingIndicatorImplTest method testGetRegexFail1NotJavaRegex.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
*/
@Test
public void testGetRegexFail1NotJavaRegex() {
// RegexpMatchingIndicator
RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// ~RegexpMatchingIndicator
// IndicatorParameters
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// ~IndicatorParameters
// Domain
Domain createDomain = DomainFactory.eINSTANCE.createDomain();
EList<Pattern> patterns = createDomain.getPatterns();
// ~Domain
// Pattern
Pattern createJavaPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
patterns.add(createJavaPattern);
patterns.add(createSQLPattern);
patterns.add(createMSSQLPattern);
// ~Pattern
// init java Pattern data
RegularExpression createJavaRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createJavaTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createJavaTdExpression.setBody(JavaRegex);
createJavaTdExpression.setLanguage("Microsoft SQL Server");
createJavaRegularExpression.setExpression(createJavaTdExpression);
createJavaRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
EList<PatternComponent> components = createJavaPattern.getComponents();
components.add(createJavaRegularExpression);
// ~init java Pattern data
createIndicatorParameters.setDataValidDomain(createDomain);
createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
TdColumn column = RelationalFactory.eINSTANCE.createTdColumn();
MetadataTable mdColumn = RelationalFactory.eINSTANCE.createTdTable();
column.setTable(mdColumn);
createRegexpMatchingIndicator.setAnalyzedElement(column);
// call getRegex()
String regexResult = createRegexpMatchingIndicator.getRegex();
// ~call getRegex()
Assert.assertTrue(regexResult == null);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class RegexpMatchingIndicatorImplTest method testGetRegexWithDefaultSQLWhenNoJava.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
*/
@Test
public void testGetRegexWithDefaultSQLWhenNoJava() {
// RegexpMatchingIndicator
RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// ~RegexpMatchingIndicator
// IndicatorParameters
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// ~IndicatorParameters
// Domain
Domain createDomain = DomainFactory.eINSTANCE.createDomain();
EList<Pattern> patterns = createDomain.getPatterns();
// ~Domain
// Pattern
Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
patterns.add(createSQLPattern);
patterns.add(createMSSQLPattern);
// ~Pattern
// init default:SQL Pattern data
RegularExpression createDefaultExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createDefaultTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createDefaultTdExpression.setBody("'sql body'");
createDefaultTdExpression.setLanguage("SQL");
createDefaultExpression.setExpression(createDefaultTdExpression);
createDefaultExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
EList<PatternComponent> components = createSQLPattern.getComponents();
components.add(createDefaultExpression);
// ~init default Pattern data
createIndicatorParameters.setDataValidDomain(createDomain);
createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
// call getRegex()
String regexResult = createRegexpMatchingIndicator.getRegex();
// ~call getRegex()
Assert.assertTrue("sql body".equalsIgnoreCase(regexResult));
}
Aggregations