Commit 2483b1b9 authored by npedot's avatar npedot
Browse files

adds théo ex2, ex3

parent 98ff19f0
......@@ -18,4 +18,58 @@ class DatabaseTest {
}
@Test
fun test_parse_trans2_database() {
// given
val dbXml = DatabaseTest::class.java.getResource("/db/trans2/ex2_database.xml").readText()
// when
val db = XMLSerializerJacksonAdapter().deserializeDatabase(dbXml)
// then
assertEquals("",db.id)
}
@Test
fun test_parse_trans3_database() {
// given
val dbXml = DatabaseTest::class.java.getResource("/db/trans3/ex3_database.xml").readText()
// when
val db = XMLSerializerJacksonAdapter().deserializeDatabase(dbXml)
// then
assertEquals("",db.id)
}
@Test
fun test_table_with_condition() {
// given
val table = Table()
table.name= "pure_person"
table.view="person"
table.condition="person.T=null AND person.S=null"
val colSSN = Column("SSN", "id.SSN", "dbname.SSN")
colSSN.nullable=false
table.columns.add(colSSN)
val db = Database()
db.schema.tables().add(table)
// when
val dbXml = XMLSerializerJacksonAdapter().prettyDatabase(db)
// then
assertEquals("""
<database name="" id="" source="">
<schema name="" id="">
<tables>
<tables name="pure_person" id="" view="person" condition="person.T=null AND person.S=null">
<columns>
<columns name="SSN" id="id.SSN" dbname="dbname.SSN" nullable="false" dbtype=""/>
</columns>
</tables>
</tables>
<constraints/>
</schema>
<mappings/>
</database>
""".trimIndent(),dbXml)
}
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ class ApplyChangeSetUseCaseTest {
<tables>
<tables name="person" id="" view="" condition="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
</columns>
</tables>
</tables>
......@@ -73,12 +73,12 @@ class ApplyChangeSetUseCaseTest {
<constraints name="person.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
......@@ -106,15 +106,15 @@ class ApplyChangeSetUseCaseTest {
<tables>
<tables name="person1" id="" view="" condition="">
<columns>
<columns name="K" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="T" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="K" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="T" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
<tables name="person2" id="" view="" condition="">
<columns>
<columns name="T" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="T" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</tables>
......@@ -200,14 +200,14 @@ class ApplyChangeSetUseCaseTest {
<createConstraint name="pkey_person" id="" type="PRIMARY_KEY">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</createConstraint>
......@@ -225,9 +225,9 @@ class ApplyChangeSetUseCaseTest {
<tables>
<tables name="person" id="t1" view="" condition="">
<columns>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</tables>
......@@ -235,14 +235,14 @@ class ApplyChangeSetUseCaseTest {
<constraints name="pkey_person" id="" type="PRIMARY_KEY">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</constraints>
......@@ -281,14 +281,14 @@ class ApplyChangeSetUseCaseTest {
<createConstraint name="person_employee.doubleInc1" id="cdi1" type="DOUBLE_INCLUSION">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="employee">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</createConstraint>
......@@ -304,16 +304,16 @@ class ApplyChangeSetUseCaseTest {
<tables>
<tables name="person" id="t1" view="" condition="">
<columns>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
<tables name="employee" id="t2" view="" condition="">
<columns>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="salary" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="salary" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</tables>
......@@ -321,14 +321,14 @@ class ApplyChangeSetUseCaseTest {
<constraints name="person_employee.doubleInc1" id="cdi1" type="DOUBLE_INCLUSION">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="employee">
<columns>
<columns name="surname" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" dbname="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</constraints>
......
......@@ -9,6 +9,7 @@ import unibz.cs.semint.kprime.domain.ddl.Constraint
import unibz.cs.semint.kprime.domain.ddl.Source
import unibz.cs.semint.kprime.usecase.common.XMLSerializeUseCase
import java.io.File
import kotlin.test.assertEquals
class XMLSerializerConstraintTest {
......@@ -51,12 +52,12 @@ class XMLSerializerConstraintTest {
val fileContent = File("target/test-classes/constraint_with_two_source_columns_three_target_columns.xml")
.readLines().joinToString(System.lineSeparator())
//assertEquals("",serializedConstraint)
val myDiff = DiffBuilder.compare(serializedConstraint)
.ignoreWhitespace()
.withTest(fileContent)
.checkForSimilar().build()
Assert.assertFalse(myDiff.toString(), myDiff.hasDifferences());
//assertEquals("",serializedConstraint)
}
@Test
......
<constraint name="" id="idconst1" type="FOREIGN_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
</columns>
</target>
</constraint>
\ No newline at end of file
<constraint name="" id="idconst1" type="PRIMARY_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
</columns>
</source>
<target name="" id="" table="">
......
<constraint name="" id="idconst1" type="">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" dbname="" dbtype="" nullable="false"/>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
\ No newline at end of file
<database name="" id="" source="">
<schema name="" id="">
<tables>
<table id="1" name="ITDepartment" condition="" view="">
<columns>
<columns id="rel1att0" name="DepartmentID" nullable="false"/>
<columns id="rel1att1" name="Speciality" nullable="false"/>
</columns>
</table>
<table id="2" name="Worker" condition="" view="">
<columns>
<columns id="rel2att0" name="DepartmentID" nullable="false"/>
<columns id="rel2att1" name="WorkerID" nullable="false"/>
<columns id="rel2att2" name="Address" nullable="false"/>
<columns id="rel2att3" name="Name" nullable="false"/>
</columns>
</table>
</tables>
<constraints>
<constraint name="Worker.FUNCTIONAL1" id="FUNCTIONAL1" type="FUNCTIONAL" >
<source id="" name="" table="Worker" >
<columns>
<columns id="" name="WorkerID" />
</columns>
</source>
<target name="" id="" table="Worker">
<columns>
<columns id="" name="Address" />
</columns>
</target>
</constraint>
<constraint name="ITDepartment-Worker.INCLUSION1" id="INCLUSION1" type="INCLUSION" >
<source name ="" id ="" table="ITDepartment" >
<columns>
<columns id="" name="DepartmentID" />
</columns>
</source>
<target name="" id="" table="Worker">
<columns>
<columns id="" name="DepartmentID" />
</columns>
</target>
</constraint>
</constraints>
</schema>
</database>
\ No newline at end of file
<database name="" id="" source="">
<schema name="" id="">
<tables>
<table id="1" name=" R1" condidion="" view="">
<columns>
<column var="ATT" id="" name="" />
<column var="REST1" id="" name="" />
</columns>
</table>
<table id="2" name=" R2" condidion="" view="">
<columns>
<column var="ATT" id="" name="" />
<column var="LHS" id="" name="" />
<column var="RHS" id="" name="" />
<column var="REST2" id="" name="" />
</columns>
</table>
</tables>
<constraints>
<constraint name="R2.FUNCTIONAL1" id="FUNCTIONAL1" type="FUNCTIONAL" >
<source name ="" id ="" table="R2" >
<columns>
<column var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="R2">
<columns>
<columns var="RHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
<constraint name="R1-R2.INCLUSION1" id="INCLUSION1" type="INCLUSION" >
<source name ="" id =""table="R1" >
<columns>
<column var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="R2">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
<constraint name="R1.CONS.1" id="CONS1" type="CONS" >
<source name ="" id ="" table="R1" constraint="k">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="REST1" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
</constraint>
<constraint name="R2.CONS.2" id="CONS2" type="CONS" >
<source name ="" id ="" table="R2" constraint="l">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="RHS" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="REST2" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
</constraint>
<constraint name="ATT.IS_NOT1" id="IS_NOT1" type="IS_NOT" >
<source name ="" id ="">
<columns>
<column var="ATT" id="" name="" nullable="false"/>
</colunms>
</source>
</constraint>
<constraint name="LHS.IS_NOT2" id="IS_NOT2" type="IS_NOT" >
<source name ="" id ="">
<columns>
<column var="LHS" id="" name="" nullable="false"/>
</colunms>
</source>
</constraint>
<constraint name="RHS.IS_NOT3" id="IS_NOT3" type="IS_NOT" >
<source name ="" id ="">
<columns>
<column var="RHS" id="" name="" nullable="false"/>
</colunms>
</source>
</constraint>
<constraint name="REST1.IS_NOT4" id="IS_NOT4" type="IS_NOT" >
<source name ="" id ="">
<columns>
<column var="REST1" id="" name="" nullable="false"/>
</colunms>
</source>
</constraint>
<constraint name="REST2.IS_NOT5" id="IS_NOT5" type="IS_NOT" >
<source name ="" id ="">
<columns>
<column var="REST2" id="" name="" nullable="false"/>
</colunms>
</source>
</constraint>
<constraint name="ATT^l.SUBSET6" id="SUBSET6" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="ATT^k"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="ATT^l" id="" name=""/>
</columns>
</target>
</constraint>
<constraint name="ATT.SUBSET7" id="SUBSET7" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="ATT^k"id="" name=""/>
<column var="ATT^l"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="ATT" id="" name=""/>
</columns>
</target>
</constraint>
<constraint name="LHS.SUBSET8" id="SUBSET8" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="LHS^l"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="LHS" id="" name=""/>
</columns>
</target>
</constraint>
<constraint name="RHS.SUBSET9" id="SUBSET9" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="RHS^l"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="RHS" id="" name=""/>
</columns>
</target>
</constraint>
<constraint name="REST1.SUBSET10" id="SUBSET10" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="REST1^k"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="REST1" id="" name=""/>
</columns>
</target>
</constraint>
<constraint name="REST2.SUBSET11" id="SUBSET11" type="SUBSET" >
<source id ="" name="">
<columns>
<column var="REST2^l"id="" name=""/>
</column>
</source>
<target id="" name="">
<columns>
<column var="REST2" id="" name=""/>
</columns>
</target>
</constraint>
</constraints>
</schema>
</database>
\ No newline at end of file
<database name="" id="" source="">
<schema name="" id="">
<tables>
<table id="1" name=" R1" condidion="" view="">
<columns>
<column var="ATT" id="" name="" />
<column var="REST1" id="" name="" />
</columns>
</table>
<table id="2" name=" R2" condidion="" view="">
<columns>
<column var="ATT" id="" name="" />
<column var="LHS" id="" name="" />
<column var="REST2" id="" name="" />
</columns>
</table>
<table id="3" name=" R3" condidion="" view="">
<columns>
<column var="LHS" id="" name="" />
<column var="RHS" id="" name="" />
</columns>
</table>
</tables>
<constraints>
<constraint name="R3.FUNCTIONAL1" id="FUNCTIONAL1" type="FUNCTIONAL" >
<source name ="" id ="" table="R3" >
<columns>
<column var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="R3">
<columns>
<columns var="RHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
<constraint name="R3.PRIMARY_KEY1" id="PRIMARY_KEY1" type="PRIMARY_KEY" >
<source name ="" id ="" table="R3" >
<columns>
<columns var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
</constraint>
<constraint name="R1-R2.INCLUSION1" id="INCLUSION1" type="INCLUSION" >
<source name ="" id =""table="R1" >
<columns>
<column var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="R2">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
<constraint name="R2-R3.DOUBLE_INCLUSION2" id="DOUBLE_INCLUSION2" type="DOUBLE_INCLUSION" >
<source name ="" id =""table="R2" >
<columns>
<column var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="R3">
<columns>
<columns var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
<constraint name="R1.CONS.1" id="CONS1" type="CONS" >
<source name ="" id ="" table="R1" constraint="k">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="REST1" id="" name="" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
</constraint>
<constraint name="R2.CONS.2" id="CONS2" type="CONS" >
<source name ="" id ="" table="R2" constraint="l">
<columns>
<columns var="ATT" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="LHS" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="RHS" id="" name="" dbname="" nullable="false" dbtype=""/>
<columns var="REST2" id="" name="" dbname="" nullable="false" dbtype=""/>