Skip to content
Permalink
Browse files

module renamed to dbconstraint / package renamed to org.evomaster.dbc…

…onstraint
  • Loading branch information...
jgaleotti committed May 5, 2019
1 parent 715af79 commit fd71335c41d618498e4cfc52104ded2f42c85874
Showing with 97 additions and 99 deletions.
  1. +2 −2 ...va/controller/src/main/java/org/evomaster/client/java/controller/internal/db/SchemaExtractor.java
  2. +2 −2 ...a/controller/src/main/java/org/evomaster/client/java/controller/internal/db/SelectHeuristics.java
  3. +3 −3 .../main/java/org/evomaster/client/java/controller/internal/db/constraint/H2ConstraintExtractor.java
  4. +3 −2 client-java/controller/src/test/java/org/evomaster/client/java/controller/db/DbCleanerTestBase.java
  5. +6 −6 ...nt-java/controller/src/test/java/org/evomaster/client/java/controller/db/SqlScriptRunnerTest.java
  6. +2 −2 ...ontroller/src/test/java/org/evomaster/client/java/controller/internal/db/SchemaExtractorTest.java
  7. +2 −5 core/pom.xml
  8. +3 −3 core/src/main/kotlin/org/evomaster/core/EMConfig.kt
  9. +1 −1 core/src/main/kotlin/org/evomaster/core/database/DbAction.kt
  10. +3 −3 core/src/main/kotlin/org/evomaster/core/database/DbActionUtils.kt
  11. +1 −1 core/src/main/kotlin/org/evomaster/core/database/SqlInsertBuilder.kt
  12. +1 −1 core/src/test/kotlin/org/evomaster/core/database/SqlInsertBuilderTest.kt
  13. +2 −2 core/src/test/kotlin/org/evomaster/core/database/extract/ProxyPrintSqlExtractTest.kt
  14. +1 −1 {db-constraints → dbconstraint}/pom.xml
  15. +1 −1 .../evomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/AndConstraint.java
  16. +7 −7 ...master/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ConstraintBuilder.java
  17. +1 −1 ...evomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/EnumConstraint.java
  18. +1 −1 ...evomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/LikeConstraint.java
  19. +1 −1 ...ter/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/LowerBoundConstraint.java
  20. +1 −1 ...g/evomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/OrConstraint.java
  21. +1 −1 ...vomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/RangeConstraint.java
  22. +1 −1 ...ster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/SimilarToConstraint.java
  23. +1 −1 ...vomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/TableConstraint.java
  24. +1 −1 ...omaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/UniqueConstraint.java
  25. +1 −1 ...nstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/UnsupportedTableConstraint.java
  26. +1 −1 ...ter/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/UpperBoundConstraint.java
  27. +1 −1 ...ster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlAndCondition.java
  28. +1 −1 ...raint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlBigDecimalLiteralValue.java
  29. +1 −1 ...raint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlBigIntegerLiteralValue.java
  30. +1 −1 ...raint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlBinaryDataLiteralValue.java
  31. +1 −1 ...nstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlBooleanLiteralValue.java
  32. +1 −1 .../evomaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlColumn.java
  33. +1 −1 ...nstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlComparisonCondition.java
  34. +1 −1 ...onstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlComparisonOperator.java
  35. +1 −1 ...omaster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlCondition.java
  36. +1 −1 ...ter/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlConditionList.java
  37. +1 −1 .../constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlConditionVisitor.java
  38. +1 −1 ...aster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlInCondition.java
  39. +1 −1 ...onstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlIsNotNullCondition.java
  40. +1 −1 ...r/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlIsNullCondition.java
  41. +1 −1 ...ter/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlLikeCondition.java
  42. +1 −1 ...ster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlLiteralValue.java
  43. +1 −1 .../constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlNullLiteralValue.java
  44. +1 −1 ...aster/constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlOrCondition.java
  45. +1 −1 ...onstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlSimilarToCondition.java
  46. +1 −1 ...onstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/ast/SqlStringLiteralValue.java
  47. +3 −3 ...aint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/extract/SqlConditionTranslator.java
  48. +1 −1 ...nstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/extract/TranslationContext.java
  49. +2 −2 ...onstraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/SqlConditionParser.java
  50. +1 −1 ... → dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/SqlConditionParserException.java
  51. +2 −2 ...nt → dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/SqlConditionParserFactory.java
  52. +4 −4 ...dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/calcite/CalciteConditionParser.java
  53. +1 −1 ... dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/calcite/CalciteSqlNodeVisitor.java
  54. +4 −4 ...int → dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/jsql/JSqlConditionParser.java
  55. +2 −2 .../constraint → dbconstraint/src/main/java/org/evomaster/dbconstraint}/parser/jsql/JSqlVisitor.java
  56. +1 −1 ...er/constraint → dbconstraint/src/test/java/org/evomaster/dbconstraint}/ConstraintBuilderTest.java
  57. +4 −4 ...r/constraint → dbconstraint/src/test/java/org/evomaster/dbconstraint}/SqlConditionParserTest.java
  58. +2 −2 pom.xml
@@ -92,7 +92,7 @@ We do not do much with it anyway (at least for


/**
* Adds a unique constraint to the correspondinding ColumnDTO for the selected table.column pair.
* Adds a unique dbconstraint to the correspondinding ColumnDTO for the selected table.column pair.
* Requires the ColumnDTO to be contained in the TableDTO.
* If the column DTO is not contained, a IllegalArgumentException is thrown.
**/
@@ -161,7 +161,7 @@ private static void addConstraints(DbSchemaDto schemaDto, List<DbTableConstraint
addUniqueConstraintToColumn(tableName, tableDto, columnName);
}
} else {
throw new RuntimeException("Unknown constraint type " + constraint.getClass().getName());
throw new RuntimeException("Unknown dbconstraint type " + constraint.getClass().getName());
}

}
@@ -9,7 +9,7 @@
import org.evomaster.client.java.controller.db.DataRow;
import org.evomaster.client.java.controller.db.QueryResult;

import java.util.*;
import java.util.List;

import static org.evomaster.client.java.controller.internal.db.ParserUtils.getWhere;

@@ -139,7 +139,7 @@ public static double computeDistance(String select, QueryResult data) {

Expression where = getWhere(stmt);
if (where == null) {
//no constraint, and at least one data point
//no dbconstraint, and at least one data point
return 0;
}

@@ -70,13 +70,13 @@

} else if (constraintType.equals("REFERENTIAL")) {
/**
* This type of constraint is already handled by
* This type of dbconstraint is already handled by
* JDBC Metadata
**/
continue;
} else if (constraintType.equals("PRIMARY KEY") || constraintType.equals("PRIMARY_KEY")) {
/**
* This type of constraint is already handled by
* This type of dbconstraint is already handled by
* JDBC Metadata
**/
continue;
@@ -87,7 +87,7 @@
tableCheckExpressions.add(constraint);

} else {
throw new RuntimeException("Unknown constraint type : " + constraintType);
throw new RuntimeException("Unknown dbconstraint type : " + constraintType);
}

}
@@ -6,7 +6,8 @@
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* Created by arcuri82 on 25-Mar-19.
@@ -55,7 +56,7 @@ public void testFKs() throws Exception{

SqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Foo(x int, primary key (x));");
SqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Bar(y int, primary key (y));");
SqlScriptRunner.execCommand(getConnection(), "alter table Bar add constraint FK foreign key (y) references Foo;");
SqlScriptRunner.execCommand(getConnection(), "alter table Bar add dbconstraint FK foreign key (y) references Foo;");

//can't insert before Foo
assertThrows(Exception.class, () ->
@@ -10,9 +10,9 @@
import java.util.List;

import static io.restassured.RestAssured.given;
import static org.evomaster.client.java.controller.db.dsl.SqlDsl.sql;
import static org.evomaster.client.java.controller.api.ControllerConstants.BASE_PATH;
import static org.evomaster.client.java.controller.api.ControllerConstants.DATABASE_COMMAND;
import static org.evomaster.client.java.controller.db.dsl.SqlDsl.sql;
import static org.junit.jupiter.api.Assertions.*;

public class SqlScriptRunnerTest extends DatabaseTestTemplate {
@@ -90,7 +90,7 @@ public void testInsertWhenForeignKey() throws Exception {
", barId bigint not null " +
");" +
" CREATE TABLE Bar(id bigint generated by default as identity);" +
" ALTER TABLE Foo add constraint barIdKey foreign key (barId) references Bar;\n"
" ALTER TABLE Foo add dbconstraint barIdKey foreign key (barId) references Bar;\n"
);

QueryResult res = SqlScriptRunner.execCommand(getConnection(), "SELECT * FROM Bar;");
@@ -125,7 +125,7 @@ public void testIdentityExtractGeneratedKey() throws Exception {
" id bigint generated by default as identity " +
", x integer " +
", primary key (id));" +
" ALTER TABLE Foo add constraint barIdKey foreign key (barId) references Bar;\n"
" ALTER TABLE Foo add dbconstraint barIdKey foreign key (barId) references Bar;\n"
);

QueryResult res = SqlScriptRunner.execCommand(getConnection(), "SELECT * FROM Bar;");
@@ -161,7 +161,7 @@ public void testInsertionListWithGeneratedKeys() throws Exception {
" id bigint generated by default as identity " +
", x integer " +
", primary key (id));" +
" ALTER TABLE Foo add constraint barIdKey foreign key (barId) references Bar;\n"
" ALTER TABLE Foo add dbconstraint barIdKey foreign key (barId) references Bar;\n"
);

QueryResult res = SqlScriptRunner.execCommand(getConnection(), "SELECT * FROM Bar;");
@@ -281,10 +281,10 @@ public void testDoubleIndirectForeignKey() throws Exception {
");"
+
"alter table Table2 " +
" add constraint FKTable2 foreign key (id) references Table1;"
" add dbconstraint FKTable2 foreign key (id) references Table1;"
+
"alter table Table3 " +
" add constraint FKTable3 foreign key (id) references Table2;"
" add dbconstraint FKTable3 foreign key (id) references Table2;"
);

List<InsertionDto> insertions = sql()
@@ -117,7 +117,7 @@ public void testBasicForeignKey() throws Exception {
", barId bigint not null " +
");" +
" CREATE TABLE Bar(id bigint generated by default as identity);" +
" ALTER TABLE Foo add constraint barIdKey foreign key (barId) references Bar;\n"
" ALTER TABLE Foo add dbconstraint barIdKey foreign key (barId) references Bar;\n"
);

DbSchemaDto schema = SchemaExtractor.extract(getConnection());
@@ -179,7 +179,7 @@ public void testColumnUpperBoundConstraint() throws Exception {
assertTrue(fooTable.columns.stream().anyMatch(c -> c.name.equalsIgnoreCase("fooId")));
assertTrue(fooTable.columns.stream().anyMatch(c -> c.name.equalsIgnoreCase("age_max")));

// TODO check that the column constraint is actually extracted
// TODO check that the column dbconstraint is actually extracted
ColumnDto columnDto = fooTable.columns.stream().filter(c -> c.name.equalsIgnoreCase("age_max")).findFirst().orElse(null);

assertEquals("INTEGER", columnDto.type);
@@ -126,13 +126,10 @@
</dependency>
<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-db-constraints</artifactId>
</dependency>
<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-db-constraints</artifactId>
<artifactId>evomaster-dbconstraint</artifactId>
</dependency>


</dependencies>

<build>
@@ -162,7 +162,7 @@ class EMConfig {
* chosen on the command line
*
*
* @throws IllegalArgumentException if there are constraint violations
* @throws IllegalArgumentException if there are dbconstraint violations
*/
fun updateProperties(options: OptionSet) {

@@ -213,15 +213,15 @@ class EMConfig {
m.annotations.find { it is Min }?.also {
it as Min
if(parameterValue.toDouble() < it.min){
throw IllegalArgumentException("Failed to handle Min ${it.min} constraint for" +
throw IllegalArgumentException("Failed to handle Min ${it.min} dbconstraint for" +
" parameter '${m.name}' with value $parameterValue")
}
}

m.annotations.find { it is Max }?.also {
it as Max
if(parameterValue.toDouble() > it.max){
throw IllegalArgumentException("Failed to handle Max ${it.max} constraint for" +
throw IllegalArgumentException("Failed to handle Max ${it.max} dbconstraint for" +
" parameter '${m.name}' with value $parameterValue")
}
}
@@ -235,7 +235,7 @@ class DbAction(
*/
/*
This is a nasty case, as it is a blob of binary data.
Could be any format, and likely no constraint in the DB schema,
Could be any format, and likely no dbconstraint in the DB schema,
where the actual constraints are in the SUT code.
This is also what for example can be used by Hibernate to represent
a ZoneDataTime before Java 8 support.
@@ -1,11 +1,11 @@
package org.evomaster.core.database

import org.evomaster.core.Lazy
import org.evomaster.core.search.Action
import org.evomaster.core.search.gene.Gene
import org.evomaster.core.search.gene.SqlForeignKeyGene
import org.evomaster.core.search.gene.SqlPrimaryKeyGene
import org.evomaster.core.search.service.Randomness
import org.evomaster.core.Lazy

object DbActionUtils {

@@ -189,13 +189,13 @@ object DbActionUtils {

val tableName = action.table.name

//handle unique constraint
//handle unique dbconstraint
action.seeGenes().forEach { g ->
val columnName = g.name

/*
Is the current gene representing a column in database for which we need
to enforce a unique constraint?
to enforce a unique dbconstraint?
*/
val isUnique = action.table.columns.any {
it.name == columnName && !it.autoIncrement && it.unique
@@ -5,14 +5,14 @@ import org.evomaster.client.java.controller.api.dto.database.operations.QueryRes
import org.evomaster.client.java.controller.api.dto.database.schema.DatabaseType
import org.evomaster.client.java.controller.api.dto.database.schema.DbSchemaDto
import org.evomaster.client.java.controller.api.dto.database.schema.TableDto
import org.evomaster.constraint.*
import org.evomaster.core.database.schema.Column
import org.evomaster.core.database.schema.ColumnDataType
import org.evomaster.core.database.schema.ForeignKey
import org.evomaster.core.database.schema.Table
import org.evomaster.core.search.gene.Gene
import org.evomaster.core.search.gene.ImmutableDataHolderGene
import org.evomaster.core.search.gene.SqlPrimaryKeyGene
import org.evomaster.dbconstraint.*


class SqlInsertBuilder(
@@ -147,7 +147,7 @@ class SqlInsertBuilderTest {
id bigint generated by default as identity,
primary key (id)
);
ALTER TABLE Foo add constraint barIdKey foreign key (barId) references Bar;
ALTER TABLE Foo add dbconstraint barIdKey foreign key (barId) references Bar;
""")

val dto = SchemaExtractor.extract(connection)
@@ -1,7 +1,7 @@
package org.evomaster.core.database.extract

import org.evomaster.client.java.controller.internal.db.SchemaExtractor
import org.evomaster.client.java.controller.api.dto.database.schema.DatabaseType
import org.evomaster.client.java.controller.internal.db.SchemaExtractor
import org.evomaster.core.database.DbActionTransformer
import org.evomaster.core.database.DbActionUtils
import org.evomaster.core.database.SqlInsertBuilder
@@ -46,7 +46,7 @@ class ProxyPrintSqlExtractTest : ExtractTestBaseH2() {
/**
* The schema includes an alter table command that specifies that
* table USERS has a unique column USERNAME:
* alter table users add constraint UK_r43af9ap4edm43mmtq01oddj6 unique (username);
* alter table users add dbconstraint UK_r43af9ap4edm43mmtq01oddj6 unique (username);
*/
assertEquals(true, schema.tables.find { it.name == "USERS" }!!.columns.find { it.name == "USERNAME" }!!.unique)

@@ -21,7 +21,7 @@
</parent>

<groupId>org.evomaster</groupId>
<artifactId>evomaster-db-constraints</artifactId>
<artifactId>evomaster-dbconstraint</artifactId>
<packaging>jar</packaging>


@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,11 +1,11 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import org.evomaster.constraint.ast.SqlCondition;
import org.evomaster.constraint.extract.SqlConditionTranslator;
import org.evomaster.constraint.extract.TranslationContext;
import org.evomaster.constraint.parser.SqlConditionParser;
import org.evomaster.constraint.parser.SqlConditionParserException;
import org.evomaster.constraint.parser.SqlConditionParserFactory;
import org.evomaster.dbconstraint.ast.SqlCondition;
import org.evomaster.dbconstraint.extract.SqlConditionTranslator;
import org.evomaster.dbconstraint.extract.TranslationContext;
import org.evomaster.dbconstraint.parser.SqlConditionParser;
import org.evomaster.dbconstraint.parser.SqlConditionParserException;
import org.evomaster.dbconstraint.parser.SqlConditionParserFactory;

public class ConstraintBuilder {

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.List;
import java.util.Objects;
@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;


import java.util.Arrays;
@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.List;
import java.util.Objects;
@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint;
package org.evomaster.dbconstraint;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint.ast;
package org.evomaster.dbconstraint.ast;

import java.util.Objects;

@@ -1,4 +1,4 @@
package org.evomaster.constraint.ast;
package org.evomaster.dbconstraint.ast;

import java.math.BigDecimal;
import java.util.Objects;
@@ -1,4 +1,4 @@
package org.evomaster.constraint.ast;
package org.evomaster.dbconstraint.ast;

import java.math.BigInteger;
import java.util.Objects;
@@ -1,4 +1,4 @@
package org.evomaster.constraint.ast;
package org.evomaster.dbconstraint.ast;

public class SqlBinaryDataLiteralValue extends SqlLiteralValue {

@@ -1,4 +1,4 @@
package org.evomaster.constraint.ast;
package org.evomaster.dbconstraint.ast;

import java.util.Objects;

Oops, something went wrong.

0 comments on commit fd71335

Please sign in to comment.
You can’t perform that action at this time.