Search in sources :

Example 26 with IPersistentClass

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

the class CoreMappingTestHelper method testOpenMappingDiagram.

public void testOpenMappingDiagram() {
    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];
        IEditorPart editor = null;
        Throwable ex = null;
        try {
            editor = new OpenDiagramActionDelegate().openEditor(persClass, consCFG);
        } catch (PartInitException e) {
            ex = e;
        }
        if (ex == null) {
            ex = Utils.getExceptionIfItOccured(editor);
        }
        if (ex != null) {
            ex.printStackTrace();
            String out = NLS.bind(TestConsoleMessages.OpenMappingDiagramTest_mapping_diagram_for_not_opened, new Object[] { persClass.getClassName(), ex.getMessage() });
            Assert.fail(out);
        }
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IEditorPart(org.eclipse.ui.IEditorPart) OpenDiagramActionDelegate(org.jboss.tools.hibernate.ui.view.OpenDiagramActionDelegate) PartInitException(org.eclipse.ui.PartInitException) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 27 with IPersistentClass

use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass 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 28 with IPersistentClass

use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass 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 29 with IPersistentClass

use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass 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)

Example 30 with IPersistentClass

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

the class ConfigurationFacadeTest method testGetClassMappings.

@Test
public void testGetClassMappings() {
    configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
    Iterator<IPersistentClass> iterator = configurationFacade.getClassMappings();
    Assert.assertFalse(iterator.hasNext());
    configuration.configure();
    configuration.buildMappings();
    configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
    iterator = configurationFacade.getClassMappings();
    IPersistentClass persistentClassFacade = iterator.next();
    Assert.assertEquals("org.jboss.tools.hibernate.runtime.v_3_6.internal.test.Foo", persistentClassFacade.getClassName());
}
Also used : IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.Test)

Aggregations

IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)175 Test (org.junit.Test)97 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)60 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)51 RootClass (org.hibernate.mapping.RootClass)47 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)46 PersistentClass (org.hibernate.mapping.PersistentClass)43 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)19 AbstractPersistentClassFacade (org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade)16 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)16 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)14 OneToMany (org.hibernate.mapping.OneToMany)12 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)8 JoinedSubclass (org.hibernate.mapping.JoinedSubclass)8 PrimitiveArray (org.hibernate.mapping.PrimitiveArray)8 Property (org.hibernate.mapping.Property)8 SingleTableSubclass (org.hibernate.mapping.SingleTableSubclass)8 IEditorPart (org.eclipse.ui.IEditorPart)7 PartInitException (org.eclipse.ui.PartInitException)7