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;
}
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();
}
Aggregations