Search in sources :

Example 6 with DbObject

use of org.alfresco.util.schemacomp.model.DbObject in project alfresco-repository by Alfresco.

the class DefaultComparisonUtilsTest method collectionPropertyIsNotComparedWhenValidatorTakesResponsibility.

@Test
public void collectionPropertyIsNotComparedWhenValidatorTakesResponsibility() {
    Collection<Object> refCollection = new ArrayList<Object>();
    refCollection.add(123);
    refCollection.add("both");
    DbObject refDbObj = new DbObjectWithCollection("left", refCollection);
    DbProperty refCollProp = new DbProperty(refDbObj, "collection");
    Collection<Object> targetCollection = new ArrayList<Object>();
    targetCollection.add(234);
    targetCollection.add("both");
    DbObject targetDbObj = new DbObjectWithCollection("right", targetCollection);
    DbProperty targetCollProp = new DbProperty(targetDbObj, "collection");
    DbValidator validator = mock(DbValidator.class);
    when(validator.validates("collection")).thenReturn(true);
    refDbObj.getValidators().add(validator);
    comparisonUtils.compareSimpleCollections(refCollProp, targetCollProp, ctx);
    // No information should be reported...
    verify(differences, never()).add(Where.IN_BOTH_NO_DIFFERENCE, dbPropForValue(refDbObj, "collection[1]", "both"), dbPropForValue(targetDbObj, "collection[1]", "both"));
    verify(differences, never()).add(Where.ONLY_IN_REFERENCE, dbPropForValue(refDbObj, "collection[0]", 123), dbPropForValue(targetDbObj, "collection", targetCollection));
    verify(differences, never()).add(Where.ONLY_IN_TARGET, dbPropForValue(refDbObj, "collection", refCollection), dbPropForValue(targetDbObj, "collection[0]", 234));
}
Also used : DbObject(org.alfresco.util.schemacomp.model.DbObject) AbstractDbObject(org.alfresco.util.schemacomp.model.AbstractDbObject) ArrayList(java.util.ArrayList) DbObject(org.alfresco.util.schemacomp.model.DbObject) AbstractDbObject(org.alfresco.util.schemacomp.model.AbstractDbObject) DbValidator(org.alfresco.util.schemacomp.validator.DbValidator) Test(org.junit.Test)

Example 7 with DbObject

use of org.alfresco.util.schemacomp.model.DbObject in project alfresco-repository by Alfresco.

the class RedundantDbObjectTest method describe.

@Test
public void describe() {
    DbObject reference = new MyDbObject("reference");
    List<DbObject> matches = makeMatches(3);
    RedundantDbObject redundantDBO = new RedundantDbObject(reference, matches);
    assertEquals("Redundancy: 3 items matching MyDbObject[name=reference], " + "matches: MyDbObject[name=match1], MyDbObject[name=match2], MyDbObject[name=match3]", redundantDBO.describe());
}
Also used : AbstractDbObject(org.alfresco.util.schemacomp.model.AbstractDbObject) DbObject(org.alfresco.util.schemacomp.model.DbObject) Test(org.junit.Test)

Example 8 with DbObject

use of org.alfresco.util.schemacomp.model.DbObject in project alfresco-repository by Alfresco.

the class RedundantDbObjectTest method describeTooManyMatches.

@Test
public void describeTooManyMatches() {
    DbObject reference = new MyDbObject("reference");
    List<DbObject> matches = makeMatches(4);
    RedundantDbObject redundantDBO = new RedundantDbObject(reference, matches);
    assertEquals("4 redundant items? reference: MyDbObject[name=reference], " + "matches: MyDbObject[name=match1], MyDbObject[name=match2], MyDbObject[name=match3] and 1 more...", redundantDBO.describe());
}
Also used : AbstractDbObject(org.alfresco.util.schemacomp.model.AbstractDbObject) DbObject(org.alfresco.util.schemacomp.model.DbObject) Test(org.junit.Test)

Example 9 with DbObject

use of org.alfresco.util.schemacomp.model.DbObject in project alfresco-repository by Alfresco.

the class MySQLDialectExportTester method doExportTest.

@Override
protected void doExportTest() throws Exception {
    Schema schema = getSchema();
    Table exampleTable = null;
    Table otherTable = null;
    for (DbObject dbo : schema) {
        if (dbo.getName().equals("export_test_example")) {
            exampleTable = (Table) dbo;
        }
        if (dbo.getName().equals("export_test_other")) {
            otherTable = (Table) dbo;
        }
    }
    checkExampleTable(schema, exampleTable);
    checkOtherTable(schema, otherTable);
}
Also used : Table(org.alfresco.util.schemacomp.model.Table) DbObject(org.alfresco.util.schemacomp.model.DbObject) Schema(org.alfresco.util.schemacomp.model.Schema)

Example 10 with DbObject

use of org.alfresco.util.schemacomp.model.DbObject in project alfresco-repository by Alfresco.

the class DbObjectXMLTransformer method transformSchema.

private void transformSchema(Schema schema) throws SAXException {
    simpleStartTag(XML.EL_OBJECTS);
    for (DbObject dbo : schema) {
        output(dbo);
    }
    simpleEndTag(XML.EL_OBJECTS);
}
Also used : DbObject(org.alfresco.util.schemacomp.model.DbObject)

Aggregations

DbObject (org.alfresco.util.schemacomp.model.DbObject)22 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 AbstractDbObject (org.alfresco.util.schemacomp.model.AbstractDbObject)12 DbValidator (org.alfresco.util.schemacomp.validator.DbValidator)9 Table (org.alfresco.util.schemacomp.model.Table)5 Schema (org.alfresco.util.schemacomp.model.Schema)4 Index (org.alfresco.util.schemacomp.model.Index)3 Sequence (org.alfresco.util.schemacomp.model.Sequence)3 PrimaryKey (org.alfresco.util.schemacomp.model.PrimaryKey)2 Collection (java.util.Collection)1 Where (org.alfresco.util.schemacomp.Difference.Where)1 Column (org.alfresco.util.schemacomp.model.Column)1 ForeignKey (org.alfresco.util.schemacomp.model.ForeignKey)1 NameValidator (org.alfresco.util.schemacomp.validator.NameValidator)1