Search in sources :

Example 11 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSpecialRootClass.

@Test
public void testCreateSpecialRootClass() {
    Property property = new Property();
    property.setValue(new SimpleValue());
    IProperty propertyFacade = new AbstractPropertyFacade(facadeFactory, property) {
    };
    IPersistentClass specialRootClass = facadeFactory.createSpecialRootClass(propertyFacade);
    Assert.assertSame(property, ((IFacade) specialRootClass.getProperty()).getTarget());
}
Also used : AbstractPropertyFacade(org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 12 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class CoreMappingTestHelper method openPropertyTestForPackage.

private void openPropertyTestForPackage(IProperty compositeProperty, IProperty parentProperty, ConsoleConfiguration consCFG, String packageName) {
    IEditorPart editor = null;
    Throwable ex = null;
    try {
        editor = OpenMappingAction.run(consCFG, compositeProperty, parentProperty);
        boolean highlighted = Utils.hasSelection(editor);
        if (!highlighted) {
            String out = NLS.bind(TestConsoleMessages.OpenMappingFileTest_highlighted_region_for_property_is_empty_package, new Object[] { compositeProperty.getName(), packageName });
            if (Customization.USE_CONSOLE_OUTPUT)
                System.err.println(out);
            Assert.fail(out);
        }
        Object[] compProperties = propertyWorkbenchAdapter.getChildren(compositeProperty);
        for (int k = 0; k < compProperties.length; k++) {
            // test Composite properties
            Assert.assertTrue(compProperties[k] instanceof IProperty);
        // use only first level to time safe
        // openPropertyTest((Property)compProperties[k], compositeProperty, consCFG);
        }
    } catch (PartInitException e) {
        ex = e;
    } catch (JavaModelException e) {
        ex = e;
    } catch (FileNotFoundException e) {
        ex = e;
    }
    if (ex == null) {
        ex = Utils.getExceptionIfItOccured(editor);
    }
    if (ex != null) {
        String out = NLS.bind(TestConsoleMessages.OpenMappingFileTest_mapping_file_for_property_not_opened_package, new Object[] { compositeProperty.getName(), packageName, ex.getMessage() });
        Assert.fail(out);
    }
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) FileNotFoundException(java.io.FileNotFoundException) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException)

Example 13 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class CoreMappingTestHelper method testOpenSourceFileTest.

public void testOpenSourceFileTest() {
    // fail("test fail");
    final Object[] persClasses = getPersistenceClasses(true);
    final ConsoleConfiguration consCFG = getConsoleConfig();
    for (int i = 0; i < persClasses.length; i++) {
        Assert.assertTrue(persClasses[i] instanceof IPersistentClass);
        IPersistentClass persClass = (IPersistentClass) persClasses[i];
        String fullyQualifiedName = persClass.getClassName();
        // test PersistentClasses
        openTest(persClass, consCFG, fullyQualifiedName);
        Object[] fields = pcWorkbenchAdapter.getChildren(persClass);
        for (int j = 0; j < fields.length; j++) {
            if (!(fields[j] instanceof IProperty && ((IProperty) fields[j]).classIsPropertyClass())) {
                continue;
            }
            fullyQualifiedName = persClass.getClassName();
            // test Properties
            openTest(fields[j], consCFG, fullyQualifiedName);
            if (fields[j] instanceof IProperty && ((IProperty) fields[j]).isComposite()) {
                fullyQualifiedName = ((IProperty) fields[j]).getValue().getComponentClassName();
                Object[] compProperties = propertyWorkbenchAdapter.getChildren(fields[j]);
                for (int k = 0; k < compProperties.length; k++) {
                    if (!(compProperties[k] instanceof IProperty && ((IProperty) compProperties[k]).classIsPropertyClass())) {
                        continue;
                    }
                    // test Composite properties
                    openTest(compProperties[k], consCFG, fullyQualifiedName);
                }
            }
        }
    }
// close all editors
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 14 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class CoreMappingTestHelper method testOpenMappingFileTest.

public void testOpenMappingFileTest(String packageName) {
    final Object[] persClasses = getPersistenceClasses(true);
    final ConsoleConfiguration consCFG = getConsoleConfig();
    // $NON-NLS-1$
    final String testClass = "class";
    for (int i = 0; i < persClasses.length; i++) {
        Assert.assertTrue(persClasses[i] instanceof IPersistentClass);
        IPersistentClass persClass = (IPersistentClass) persClasses[i];
        openTestForPackage(persClass, consCFG, packageName);
        Object[] props = pcWorkbenchAdapter.getChildren(persClass);
        for (int j = 0; j < props.length; j++) {
            if (!(props[j] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                continue;
            }
            openTestForPackage(props[j], consCFG, packageName);
            Object[] compProperties = propertyWorkbenchAdapter.getChildren(props[j]);
            for (int k = 0; k < compProperties.length; k++) {
                // test Composite properties
                if (!(compProperties[k] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                    continue;
                }
                final IProperty prop = (IProperty) compProperties[k];
                if (testClass.equals(prop.getName()) || testClass.equals(prop.getName())) {
                    continue;
                }
                openPropertyTestForPackage((IProperty) compProperties[k], (IProperty) props[j], consCFG, packageName);
            }
        }
    }
// close all editors
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 15 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class MappingTestHelper method testOpenMappingFileTest.

public void testOpenMappingFileTest() {
    final Object[] persClasses = getPersistenceClasses(true);
    final ConsoleConfiguration consCFG = getConsoleConfig();
    // $NON-NLS-1$
    final String testClass = "class";
    for (int i = 0; i < persClasses.length; i++) {
        Assert.assertTrue(persClasses[i] instanceof IPersistentClass);
        IPersistentClass persClass = (IPersistentClass) persClasses[i];
        openTest(persClass, consCFG);
        Object[] props = pcWorkbenchAdapter.getChildren(persClass);
        for (int j = 0; j < props.length; j++) {
            if (!(props[j] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                continue;
            }
            openTest(props[j], consCFG);
            Object[] compProperties = propertyWorkbenchAdapter.getChildren(props[j]);
            for (int k = 0; k < compProperties.length; k++) {
                // test Composite properties
                if (!(compProperties[k] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                    continue;
                }
                final IProperty prop = (IProperty) compProperties[k];
                if (testClass.equals(prop.getName()) || testClass.equals(prop.getName())) {
                    continue;
                }
                openPropertyTest((IProperty) compProperties[k], (IProperty) props[j], consCFG);
            }
        }
    }
// close all editors
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Aggregations

IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)93 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)53 Property (org.hibernate.mapping.Property)40 Test (org.junit.Test)33 RootClass (org.hibernate.mapping.RootClass)27 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)20 PersistentClass (org.hibernate.mapping.PersistentClass)18 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)12 SimpleValue (org.hibernate.mapping.SimpleValue)12 AbstractPropertyFacade (org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade)12 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 FileNotFoundException (java.io.FileNotFoundException)9 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)9 Component (org.hibernate.mapping.Component)8 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)8 IEditorPart (org.eclipse.ui.IEditorPart)7 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)7 JavaModelException (org.eclipse.jdt.core.JavaModelException)6 Mappings (org.hibernate.cfg.Mappings)6 PartInitException (org.eclipse.ui.PartInitException)5