How to use accept method of org.evomaster.dbconstraint.ast.SqlIsNullCondition class

Best EvoMaster code snippet using org.evomaster.dbconstraint.ast.SqlIsNullCondition.accept

Source:SqlConditionTranslator.java Github

copy

Full Screen

...47 }48 }49 @Override50 public TableConstraint visit(SqlAndCondition andExpression, Void argument) {51 TableConstraint left = andExpression.getLeftExpr().accept(this, null);52 TableConstraint right = andExpression.getRightExpr().accept(this, null);53 return new AndConstraint(translationContext.getCurrentTableName(), left, right);54 }55 @Override56 public TableConstraint visit(SqlComparisonCondition e, Void argument) {57 SqlCondition left = e.getLeftOperand();58 SqlCondition right = e.getRightOperand();59 if (left instanceof SqlLiteralValue && right instanceof SqlColumn) {60 SqlLiteralValue leftLiteral = (SqlLiteralValue) left;61 SqlColumn rightColumn = (SqlColumn) right;62 return visit(leftLiteral, e, rightColumn);63 } else if (left instanceof SqlColumn && right instanceof SqlLiteralValue) {64 SqlColumn leftColumn = (SqlColumn) left;65 SqlLiteralValue rightLiteral = (SqlLiteralValue) right;66 return visit(leftColumn, e, rightLiteral);67 } else if (left instanceof SqlCondition && right instanceof SqlCondition) {68 TableConstraint leftTableConstraint = e.getLeftOperand().accept(this, null);69 TableConstraint rightTableConstraint = e.getRightOperand().accept(this, null);70 if (e.getSqlComparisonOperator().equals(EQUALS_TO)) {71 return new IffConstraint(translationContext.getCurrentTableName(), leftTableConstraint, rightTableConstraint);72 }73 }74 // TODO This translation should be implemented75 throw new SqlCannotBeTranslatedException(e.toSql() + " cannot be translated yet");76 }77 private TableConstraint visit(SqlColumn leftColumn, SqlComparisonCondition e, SqlLiteralValue rightLiteral) {78 final String tableName = getTableName(leftColumn);79 final String columnName = leftColumn.getColumnName();80 if (rightLiteral instanceof SqlBigIntegerLiteralValue) {81 long value = ((SqlBigIntegerLiteralValue) rightLiteral).getBigInteger().longValue();82 switch (e.getSqlComparisonOperator()) {83 case EQUALS_TO:84 return new RangeConstraint(tableName, columnName, value, value);85 case GREATER_THAN:86 return new LowerBoundConstraint(tableName, columnName, value + 1);87 case GREATER_THAN_OR_EQUAL:88 return new LowerBoundConstraint(tableName, columnName, value);89 case LESS_THAN:90 return new UpperBoundConstraint(tableName, columnName, value - 1);91 case LESS_THAN_OR_EQUAL:92 return new UpperBoundConstraint(tableName, columnName, value);93 default:94 throw new UnsupportedOperationException(UNEXPECTED_COMPARISON_OPERATOR_MESSAGE + e.getSqlComparisonOperator());95 }96 } else if (rightLiteral instanceof SqlStringLiteralValue) {97 SqlStringLiteralValue stringLiteralValue = (SqlStringLiteralValue) rightLiteral;98 if (e.getSqlComparisonOperator().equals(EQUALS_TO)) {99 return new EnumConstraint(tableName, columnName, Collections.singletonList(stringLiteralValue.getStringValue()));100 } else {101 throw new UnsupportedOperationException(UNEXPECTED_COMPARISON_OPERATOR_MESSAGE + e.getSqlComparisonOperator());102 }103 } else {104 throw new UnsupportedOperationException("Unsupported literal " + rightLiteral);105 }106 }107 private TableConstraint visit(SqlLiteralValue leftLiteral, SqlComparisonCondition e, SqlColumn rightColumn) {108 if (leftLiteral instanceof SqlBigIntegerLiteralValue) {109 long value = ((SqlBigIntegerLiteralValue) leftLiteral).getBigInteger().longValue();110 final String tableName = getTableName(rightColumn);111 final String columnName = rightColumn.getColumnName();112 switch (e.getSqlComparisonOperator()) {113 case EQUALS_TO:114 return new RangeConstraint(tableName, columnName, value, value);115 case GREATER_THAN:116 return new UpperBoundConstraint(tableName, columnName, value - 1);117 case GREATER_THAN_OR_EQUAL:118 return new UpperBoundConstraint(tableName, columnName, value);119 case LESS_THAN:120 return new LowerBoundConstraint(tableName, columnName, value + 1);121 case LESS_THAN_OR_EQUAL:122 return new LowerBoundConstraint(tableName, columnName, value);123 default:124 throw new UnsupportedOperationException(UNEXPECTED_COMPARISON_OPERATOR_MESSAGE + e.getSqlComparisonOperator());125 }126 } else {127 throw new UnsupportedOperationException("Unsupported literal " + e.getSqlComparisonOperator());128 }129 }130 @Override131 public TableConstraint visit(SqlInCondition inExpression, Void argument) {132 SqlColumn column = inExpression.getSqlColumn();133 String tableName = getTableName(column);134 String columnName = column.getColumnName();135 SqlConditionList rightItemsList = inExpression.getLiteralList();136 List<String> stringValues = new ArrayList<>();137 for (SqlCondition expressionValue : rightItemsList.getSqlConditionExpressions()) {138 final String stringValue;139 if (expressionValue instanceof SqlStringLiteralValue) {140 stringValue = new StringValue(expressionValue.toSql()).getNotExcapedValue();141 } else {142 stringValue = expressionValue.toSql();143 }144 stringValues.add(stringValue);145 }146 return new EnumConstraint(tableName, columnName, stringValues);147 }148 @Override149 public TableConstraint visit(SqlNullLiteralValue e, Void argument) {150 throw new UnsupportedOperationException(THIS_METHOD_SHOULD_NOT_BE_INVOKED);151 }152 @Override153 public TableConstraint visit(SqlStringLiteralValue e, Void argument) {154 throw new UnsupportedOperationException(THIS_METHOD_SHOULD_NOT_BE_INVOKED);155 }156 @Override157 public TableConstraint visit(SqlConditionList e, Void argument) {158 throw new UnsupportedOperationException(THIS_METHOD_SHOULD_NOT_BE_INVOKED);159 }160 @Override161 public TableConstraint visit(SqlIsNotNullCondition e, Void argument) {162 String tableName = getTableName(e.getColumn());163 String columnName = e.getColumn().getColumnName();164 return new IsNotNullConstraint(tableName, columnName);165 }166 @Override167 public TableConstraint visit(SqlBinaryDataLiteralValue e, Void argument) {168 throw new UnsupportedOperationException(THIS_METHOD_SHOULD_NOT_BE_INVOKED);169 }170 @Override171 public TableConstraint visit(SqlSimilarToCondition e, Void argument) {172 String tableName = getTableName(e.getColumn());173 final String pattern = e.getPattern().getStringValue();174 return new SimilarToConstraint(tableName, e.getColumn().getColumnName(), pattern, translationContext.getDatabaseType());175 }176 @Override177 public TableConstraint visit(SqlIsNullCondition e, Void argument) {178 throw new UnsupportedOperationException(THIS_METHOD_SHOULD_NOT_BE_INVOKED);179 }180 @Override181 public TableConstraint visit(SqlLikeCondition e, Void argument) {182 String tableName = getTableName(e.getColumnName());183 String columnName = e.getColumnName().getColumnName();184 String pattern = e.getPattern().getStringValue();185 return new LikeConstraint(tableName, columnName, pattern, translationContext.getDatabaseType());186 }187 @Override188 public TableConstraint visit(SqlOrCondition e, Void argument) {189 List<TableConstraint> orConstraints = e.getOrConditions().stream().map(c -> c.accept(this, null)).collect(Collectors.toList());190 if (orConstraints.stream().allMatch(c -> c instanceof LikeConstraint)) {191 // all like constraints should have the same tablename, column and database type192 Set<String> columnNames = orConstraints193 .stream()194 .map(c -> (LikeConstraint) c)195 .map(c -> c.getColumnName())196 .collect(Collectors.toSet());197 Set<String> tableNames = orConstraints198 .stream()199 .map(c -> (LikeConstraint) c)200 .map(c -> c.getTableName())201 .collect(Collectors.toSet());202 Set<ConstraintDatabaseType> databaseTypes = orConstraints203 .stream().map(c -> (LikeConstraint) c)...

Full Screen

Full Screen

accept

Using AI Code Generation

copy

Full Screen

1package org.evomaster.dbconstraint.ast;2public class SqlIsNullCondition implements SqlCondition {3 private final SqlColumn column;4 public SqlIsNullCondition(SqlColumn column) {5 this.column = column;6 }7 public SqlColumn getColumn() {8 return column;9 }10 public <T> T accept(SqlConditionVisitor<T> visitor) {11 return visitor.visit(this);12 }13 public String toString() {14 return column + " IS NULL";15 }16}17package org.evomaster.dbconstraint.ast;18public interface SqlConditionVisitor<T> {19 T visit(SqlAndCondition andCondition);20 T visit(SqlOrCondition orCondition);21 T visit(SqlNotCondition notCondition);22 T visit(SqlComparisonCondition comparisonCondition);23 T visit(SqlIsNullCondition isNullCondition);24}25package org.evomaster.dbconstraint.ast;26public interface SqlCondition {27 <T> T accept(SqlConditionVisitor<T> visitor);28}29package org.evomaster.dbconstraint.ast;30public class SqlComparisonCondition implements SqlCondition {31 private final SqlColumn column;32 private final SqlComparisonOperator operator;33 private final SqlValue value;34 public SqlComparisonCondition(SqlColumn column, SqlComparisonOperator operator, SqlValue value) {35 this.column = column;36 this.operator = operator;37 this.value = value;38 }39 public SqlColumn getColumn() {40 return column;41 }42 public SqlComparisonOperator getOperator() {43 return operator;44 }45 public SqlValue getValue() {46 return value;47 }48 public <T> T accept(SqlConditionVisitor<T> visitor) {49 return visitor.visit(this);50 }51 public String toString() {52 return column + " " + operator + " " + value;53 }54}55package org.evomaster.dbconstraint.ast;56public enum SqlComparisonOperator {57 EQUALS("="),58 NOT_EQUALS("!="),59 LESS_THAN("<"),60 LESS_EQUALS_THAN("<="),61 GREATER_THAN(">"),62 GREATER_EQUALS_THAN(">=");63 private final String operator;64 SqlComparisonOperator(String operator) {65 this.operator = operator;66 }67 public String toString() {68 return operator;69 }70}71package org.evomaster.dbconstraint.ast;72public class SqlColumn {73 private final String tableName;74 private final String columnName;75 public SqlColumn(String tableName, String columnName) {

Full Screen

Full Screen

accept

Using AI Code Generation

copy

Full Screen

1package org.evomaster.dbconstraint.ast;2import org.evomaster.dbconstraint.parser.SqlParserVisitor;3public class SqlIsNullCondition extends SqlCondition {4 private final SqlColumn column;5 public SqlIsNullCondition(SqlColumn column) {6 this.column = column;7 }8 public SqlColumn getColumn() {9 return column;10 }11 public <T> T accept(SqlParserVisitor<T> visitor) {12 return visitor.visit(this);13 }14 public String toString() {15 return column + " IS NULL";16 }17}18package org.evomaster.dbconstraint.ast;19import org.evomaster.dbconstraint.parser.SqlParserVisitor;20public class SqlIsNotNullCondition extends SqlCondition {21 private final SqlColumn column;22 public SqlIsNotNullCondition(SqlColumn column) {23 this.column = column;24 }25 public SqlColumn getColumn() {26 return column;27 }28 public <T> T accept(SqlParserVisitor<T> visitor) {29 return visitor.visit(this);30 }31 public String toString() {32 return column + " IS NOT NULL";33 }34}35package org.evomaster.dbconstraint.ast;36import org.evomaster.dbconstraint.parser.SqlParserVisitor;37import java.util.Objects;38public class SqlNotCondition extends SqlCondition {39 private final SqlCondition condition;40 public SqlNotCondition(SqlCondition condition) {41 this.condition = condition;42 }43 public SqlCondition getCondition() {44 return condition;45 }46 public <T> T accept(SqlParserVisitor<T> visitor) {47 return visitor.visit(this);48 }49 public String toString() {50 return "NOT " + condition;51 }52 public boolean equals(Object o) {53 if (this == o) return true;54 if (!(o instanceof SqlNotCondition)) return false;55 SqlNotCondition that = (SqlNotCondition) o;56 return Objects.equals(condition, that.condition);57 }58 public int hashCode() {59 return Objects.hash(condition);60 }61}62package org.evomaster.dbconstraint.ast;63import org.evomaster.dbconstraint.parser.SqlParserVisitor;64import java.util.Objects;65public class SqlAndCondition extends SqlCondition {66 private final SqlCondition left;67 private final SqlCondition right;68 public SqlAndCondition(SqlCondition left, SqlCondition right) {

Full Screen

Full Screen

accept

Using AI Code Generation

copy

Full Screen

1package org.evomaster.dbconstraint.ast;2import org.evomaster.dbconstraint.parser.SqlParserVisitorAdapter;3import org.evomaster.dbconstraint.parser.SqlParser;4import java.util.Optional;5public class SqlIsNullCondition extends SqlCondition {6 private final SqlExpression expression;7 public SqlIsNullCondition(SqlExpression expression) {8 this.expression = expression;9 }10 public SqlExpression getExpression() {11 return expression;12 }13 public <T> T accept(SqlParserVisitorAdapter<T> visitor) {14 return visitor.visit(this);15 }16 public String toString() {17 return "ISNULL(" + expression + ")";18 }19 public Optional<SqlExpression> asExpression() {20 return Optional.empty();21 }22 public SqlIsNullCondition copy() {23 return new SqlIsNullCondition(expression.copy());24 }25 public SqlCondition negate() {26 return new SqlIsNotNullCondition(expression);27 }28 public SqlCondition toNNF() {29 return this;30 }31 public SqlCondition toCNF() {32 return this;33 }34 public SqlCondition toDNF() {35 return this;36 }37 public SqlCondition toNNF(SqlParser parser) {38 return this;39 }40 public SqlCondition toCNF(SqlParser parser) {41 return this;42 }43 public SqlCondition toDNF(SqlParser parser) {44 return this;45 }46}47package org.evomaster.dbconstraint.ast;48import org.evomaster.dbconstraint.parser.SqlParserVisitorAdapter;49import org.evomaster.dbconstraint.parser.SqlParser;50import java.util.Optional;51public class SqlIsNotNullCondition extends SqlCondition {52 private final SqlExpression expression;53 public SqlIsNotNullCondition(SqlExpression expression) {54 this.expression = expression;55 }56 public SqlExpression getExpression() {57 return expression;58 }59 public <T> T accept(SqlParserVisitorAdapter<T> visitor) {60 return visitor.visit(this);61 }62 public String toString() {63 return "ISNOTNULL(" + expression + ")";64 }65 public Optional<SqlExpression> asExpression() {66 return Optional.empty();67 }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run EvoMaster automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in SqlIsNullCondition

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful