use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionRedshiftCase1.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionRedshiftCase1() {
// TDQ-11558 msjian: test for get sql expresstion for redshift database
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
String redshiftLang = SupportDBUrlType.REDSHIFT.getLanguage();
// $NON-NLS-1$
String redshiftBody = "Amazon redshift body";
String postgresqlLang = SupportDBUrlType.POSTGRESQLEFAULTURL.getLanguage();
// $NON-NLS-1$
String postgresqlBody = "PostgreSQL body";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression3.setLanguage(postgresqlLang);
tdExpression3.setBody(postgresqlBody);
sqlGenericExpression.add(tdExpression3);
TdExpression tdExpression4 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression4.setLanguage(redshiftLang);
tdExpression4.setBody(redshiftBody);
sqlGenericExpression.add(tdExpression4);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, redshiftLang, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression4, sqlExpression);
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionRedshiftCase3.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionRedshiftCase3() {
// TDQ-11558 msjian: test for get sql expresstion for redshift database when there is no redshift and ParAccel
// and PostgreSQL defined
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
String redshiftLang = SupportDBUrlType.REDSHIFT.getLanguage();
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, redshiftLang, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression1, sqlExpression);
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetRegexpGetJavaFromContainDefault.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getRegexp(org.talend.dataquality.domain.pattern.Pattern, boolean)}.
*/
@Test
public void testGetRegexpGetJavaFromContainDefault() {
// Pattern
Pattern createPattern = PatternFactory.eINSTANCE.createPattern();
// ~Pattern
// init sql Expression data
RegularExpression createSqlRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createSqlTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createSqlTdExpression.setBody(SqlRegex);
createSqlTdExpression.setLanguage(ExecutionLanguage.SQL.getName());
createSqlRegularExpression.setExpression(createSqlTdExpression);
createSqlRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
EList<PatternComponent> components = createPattern.getComponents();
components.add(createSqlRegularExpression);
// ~init sql Expression data
// init mssql Expression data
RegularExpression createMssqlRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createMssqlTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createMssqlTdExpression.setBody(MssqlRegex);
createMssqlTdExpression.setLanguage(SupportDBUrlType.MSSQLDEFAULTURL.getLanguage());
createMssqlRegularExpression.setExpression(createMssqlTdExpression);
createMssqlRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
components = createPattern.getComponents();
components.add(createMssqlRegularExpression);
// ~init mssql Expression data
// init java Expression data
RegularExpression createJavaRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createJavaTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createJavaTdExpression.setBody(JavaRegex);
createJavaTdExpression.setLanguage(SupportDBUrlType.JAVADEFAULTURL.getLanguage());
createJavaRegularExpression.setExpression(createJavaTdExpression);
createJavaRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
components = createPattern.getComponents();
components.add(createJavaRegularExpression);
try {
DbmsLanguage dbms = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.JAVADEFAULTURL);
Assert.assertTrue(JavaRegex.equalsIgnoreCase(dbms.getRegexp(createPattern).getBody()));
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createRealPattern.
public static Pattern createRealPattern() {
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
// $NON-NLS-1$
pattern.setName("My Pattern");
RegularExpression regularExpr = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression expression = createRealExpression();
regularExpr.setExpression(expression);
pattern.getComponents().add(regularExpr);
return pattern;
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createRealExpression.
public static TdExpression createRealExpression() {
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
expression.setBody(REGEXP);
// $NON-NLS-1$
expression.setLanguage("SQL");
return expression;
}
Aggregations