How to use getTableUniqueConstraint method of org.evomaster.client.java.controller.internal.db.constraint.H2ConstraintExtractor class

Best EvoMaster code snippet using org.evomaster.client.java.controller.internal.db.constraint.H2ConstraintExtractor.getTableUniqueConstraint

Source:H2ConstraintExtractor.java Github

copy

Full Screen

...92 String constraintName = constraints.getString(CONSTRAINT_NAME);93 String constraintType = constraints.getString(CONSTRAINT_TYPE);94 switch (constraintType) {95 case UNIQUE: {96 DbTableUniqueConstraint constraint = getTableUniqueConstraint(connectionToH2, tableName,97 constraintCatalog, constraintSchema, constraintName);98 tableCheckExpressions.add(constraint);99 break;100 }101 case CHECK: {102 DbTableCheckExpression constraint = getTableCheckExpression(connectionToH2, tableName, constraintCatalog, constraintSchema, constraintName);103 tableCheckExpressions.add(constraint);104 break;105 }106 case PRIMARY_KEY:107 case PRIMARY_KEY_BLANK:108 case REFERENTIAL:109 /*110 * This type of constraint is already handled by111 * JDBC Metadata112 **/113 break;114 default:115 cannotHandle(constraintType);116 }117 }118 }119 }120 }121 return tableCheckExpressions;122 }123 private DbTableUniqueConstraint getTableUniqueConstraint(Connection connectionToH2,124 String tableName,125 String constraintCatalog,126 String constraintSchema,127 String constraintName) throws SQLException {128 try (Statement columnsUsageStatement = connectionToH2.createStatement()) {129 String columnsUsageQuery = String.format("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE "130 + "WHERE CONSTRAINT_CATALOG='%s' AND CONSTRAINT_SCHEMA='%s' AND CONSTRAINT_NAME='%s' ",131 constraintCatalog, constraintSchema, constraintName);132 try (ResultSet columnsUsageResultSet = columnsUsageStatement.executeQuery(columnsUsageQuery)) {133 List<String> uniqueColumnNames = new ArrayList<>();134 while (columnsUsageResultSet.next()) {135 String columnName = columnsUsageResultSet.getString(COLUMN_NAME);136 uniqueColumnNames.add(columnName);137 }...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful