use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testExtractRegularExpressionFunctionForHive.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
*
* case 2:Hive database expression
*/
@Test
public void testExtractRegularExpressionFunctionForHive() {
DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.HIVEDEFAULTURL);
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// Hive Database
// $NON-NLS-1$
createExpression.setBody("**");
// $NON-NLS-1$
String regularFunctionName = netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
// $NON-NLS-1$
Assert.assertEquals("REGEXP", regularFunctionName);
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testSetFunctionReturnValueCase5.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
*
* case 5:normal case
*/
@Test
public void testSetFunctionReturnValueCase5() {
// $NON-NLS-1$
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// default Database
// $NON-NLS-1$
createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
// $NON-NLS-1$
dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
// $NON-NLS-1$
Assert.assertEquals("RETURNVALUE", regularfunctionReturnValue);
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testIsApplicable.
/**
* Test method for {@link org.talend.dq.dbms.DbmsLanguage#isApplicable(orgomg.cwm.objectmodel.core.Expression)}.
*/
@Test
public void testIsApplicable() {
try {
// $NON-NLS-1$
Expression createExpression = createExpression("Mysql");
DbmsLanguage dbms = getMysqlDbmsLanguage();
Assert.assertTrue(dbms.isApplicable(createExpression));
} catch (Exception e) {
fail(e.getMessage());
}
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testSetFunctionReturnValueCase2.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
*
* case 2:Can not find the keyword for "when" in the body of expression.
*/
@Test
public void testSetFunctionReturnValueCase2() {
// $NON-NLS-1$
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// default Database
// $NON-NLS-1$
createExpression.setBody("**** RegularFunctionName(***)returnValue THEN **)****");
// $NON-NLS-1$
dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
Assert.assertEquals(StringUtils.EMPTY, regularfunctionReturnValue);
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testExtractRegularExpressionFunctionForMssql.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
*
* case 8:Mssql database expression
*/
@Test
public void testExtractRegularExpressionFunctionForMssql() {
DbmsLanguage mssqlDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.MSSQL2008URL);
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// netezza Database UDP mode
createExpression.setBody(// $NON-NLS-1$
"SELECT COUNT(CASE WHEN dbo.fn_prec_match(<%=__COLUMN_NAMES__%>,<%=__PATTERN_EXPR__%>)=1 THEN 1 END), COUNT(*) FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>");
String regularFunctionName = mssqlDbmsLanguage.extractRegularExpressionFunction(createExpression, // $NON-NLS-1$
"<%=__PATTERN_EXPR__%>");
// $NON-NLS-1$
Assert.assertEquals("dbo.fn_prec_match".toUpperCase(), regularFunctionName);
}
Aggregations