How to use cannotHandle method of org.evomaster.client.java.controller.internal.db.constraint.MySQLConstraintExtractor class

Best EvoMaster code snippet using org.evomaster.client.java.controller.internal.db.constraint.MySQLConstraintExtractor.cannotHandle

Source:MySQLConstraintExtractor.java Github

copy

Full Screen

...21 private static final String MYSQL_CONSTRAINT_TYPE = "CONSTRAINT_TYPE";22 private static final String MYSQL_CHECK_CLAUSE = "CHECK_CLAUSE";23 private static final String MYSQL_COLUMN_NAME = "COLUMN_NAME";24 private static final String MYSQL_ENUM_COLUMN_TYPE = "COLUMN_TYPE";25 private static void cannotHandle(String constraintType) {26 SimpleLogger.uniqueWarn("WARNING, EvoMaster cannot extract MySQL constraints with type '" + constraintType);27 }28 @Override29 public List<DbTableConstraint> extract(Connection connectionToMySQL, DbSchemaDto schemaDto) throws SQLException {30 String tableSchema = schemaDto.name;31 List<DbTableConstraint> constraints = new ArrayList<>();32 for (TableDto tableDto : schemaDto.tables){33 String tableName = tableDto.name;34 try (Statement statement = connectionToMySQL.createStatement()) {35 String query = String.format("SELECT *\n" +36 " FROM information_schema.table_constraints\n" +37 " WHERE table_schema = '%s'\n" +38 " AND table_name = '%s';", tableSchema, tableName);39 try (ResultSet columns = statement.executeQuery(query)) {40 while (columns.next()) {41 String type = columns.getString(MYSQL_CONSTRAINT_TYPE);42 switch (type){43 case MYSQL_CONSTRAINT_TYPE_PRIMARY_KEY:44 case MYSQL_CONSTRAINT_TYPE_FOREIGN_KEY:45 break;46 case MYSQL_CONSTRAINT_TYPE_CHECK:47 String constraintName = columns.getString(MYSQL_CONSTRAINT_NAME);48 DbTableCheckExpression check = getCheckConstraint(connectionToMySQL, tableName, constraintName);49 constraints.add(check);50 break;51 case MYSQL_CONSTRAINT_TYPE_UNIQUE:52 String uniqueConstraintName = columns.getString(MYSQL_CONSTRAINT_NAME);53 DbTableUniqueConstraint uniqueConstraint = getUniqueConstraint(connectionToMySQL, tableSchema, tableName, uniqueConstraintName);54 constraints.add(uniqueConstraint);55 break;56 default:57 cannotHandle("Unknown constraint type " + type);58 }59 }60 }61 }62 // handle enum column63 for (ColumnDto column: tableDto.columns){64 if (column.type.equalsIgnoreCase("enum")){65 DbTableCheckExpression enumConstraint = handleEnum(connectionToMySQL, tableSchema, tableName, column.name);66 constraints.add(enumConstraint);67 }68 }69 }70 return constraints;71 }...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful