use of org.talend.dataquality.indicators.IndicatorParameters 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.IndicatorParameters 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.IndicatorParameters 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.IndicatorParameters 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));
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class BinFrequencyIndicatorImplTest method testGetGroupLabel_1.
/**
* Test method for
* {@link org.talend.dataquality.indicators.impl.BinFrequencyIndicatorImpl#getFormatName(java.lang.Object)}. the
* domain parameter is set in this case.
*/
@Test
public void testGetGroupLabel_1() {
init();
IndicatorParameters parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// $NON-NLS-1$
Domain domain = DomainHelper.createContiguousClosedBinsIntoDomain("test", 2, 1, 9);
parameters.setBins(domain);
binFreqIndicator.setParameters(parameters);
binFreqIndicator.reset();
int i = 1;
String formatName = binFreqIndicator.getGroupLabel(i);
assertEquals(formatName, "id >= 1.0 AND id < 5.0");
i = 6;
formatName = binFreqIndicator.getGroupLabel(i);
assertEquals(formatName, "id >= 5.0 AND id < 9.0");
i = 12;
formatName = binFreqIndicator.getGroupLabel(i);
assertNull(formatName);
}
Aggregations