Search in sources :

Example 1 with OrmDiagram

use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram in project jbosstools-hibernate by jbosstools.

the class OrmEditPart method getOrmDiagram.

public OrmDiagram getOrmDiagram() {
    BaseElement modelTmp = (BaseElement) getModel();
    OrmDiagram res = modelTmp instanceof OrmDiagram ? (OrmDiagram) modelTmp : null;
    while (modelTmp != null && modelTmp.getParent() != null) {
        modelTmp = modelTmp.getParent();
        res = modelTmp instanceof OrmDiagram ? (OrmDiagram) modelTmp : res;
    }
    return res;
}
Also used : BaseElement(org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement) OrmDiagram(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram)

Example 2 with OrmDiagram

use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram in project jbosstools-hibernate by jbosstools.

the class OrmDiagramTest method testLoadAndSave.

public void testLoadAndSave() {
    final ConsoleConfiguration consoleConfig = context.mock(ConsoleConfiguration.class);
    final IConfiguration config = context.mock(IConfiguration.class);
    final IPersistentClass ioe = context.mock(IPersistentClass.class);
    ArrayList<IPersistentClass> rts = new ArrayList<IPersistentClass>();
    rts.add(ioe);
    final List<Object> emptyList = new ArrayList<Object>();
    final Iterator<Object> emptyListIterator = emptyList.iterator();
    // see https://jira.jboss.org/jira/browse/JBIDE-6186
    final String innerIntricateName = "myInner$Id";
    context.checking(new Expectations() {

        {
            oneOf(ioe).getEntityName();
            will(returnValue(innerIntricateName));
            allowing(consoleConfig).getConfiguration();
            will(returnValue(config));
            allowing(consoleConfig).hasConfiguration();
            will(returnValue(true));
            oneOf(ioe).getEntityName();
            will(returnValue(innerIntricateName));
            oneOf(ioe).getEntityName();
            will(returnValue(innerIntricateName));
            oneOf(ioe).isInstanceOfRootClass();
            will(returnValue(true));
            oneOf(ioe).getIdentifierProperty();
            will(returnValue(null));
            oneOf(ioe).getIdentifier();
            will(returnValue(null));
            oneOf(ioe).getPropertyIterator();
            will(returnValue(emptyListIterator));
            oneOf(ioe).getTable();
            will(returnValue(null));
            oneOf(ioe).getSubclassIterator();
            will(returnValue(emptyListIterator));
            oneOf(ioe).getIdentifier();
            will(returnValue(null));
            oneOf(ioe).getJoinIterator();
            will(returnValue(emptyListIterator));
            allowing(ioe).getClassName();
            // $NON-NLS-1$
            will(returnValue("ClassName"));
            allowing(consoleConfig).getName();
            // $NON-NLS-1$
            will(returnValue("CCName"));
            allowing(ioe).getEntityName();
            will(returnValue(innerIntricateName));
        }
    });
    final OrmDiagram ormDiagram = new // $NON-NLS-1$
    OrmDiagram(// $NON-NLS-1$
    "", // $NON-NLS-1$
    rts) {

        public ConsoleConfiguration getConsoleConfig() {
            return consoleConfig;
        }
    };
    ormDiagram.saveInXmlFile();
    // test is the folder created
    File folder = new File(ormDiagram.getStoreFolderPath().toOSString());
    assertTrue(folder.exists() && folder.isDirectory());
    // test is the file created
    File file = new File(ormDiagram.getStoreFilePath().toOSString());
    assertTrue(file.exists() && file.isFile());
    // 
    boolean res = file.delete();
    assertTrue(res);
    // 
    res = folder.delete();
    assertTrue(res);
    // GENERAL TEST:
    // check for all expectations
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ArrayList(java.util.ArrayList) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) OrmDiagram(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) File(java.io.File)

Aggregations

OrmDiagram (org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)1 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)1 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)1 BaseElement (org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement)1 Expectations (org.jmock.Expectations)1