use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class OpenMappingFileTest method openPropertyTest.
private void openPropertyTest(IProperty compositeProperty, IProperty parentProperty, ConsoleConfiguration consCFG) {
IEditorPart editor = null;
Throwable ex = null;
try {
editor = OpenMappingAction.run(consCFG, compositeProperty, parentProperty);
boolean highlighted = Utils.hasSelection(editor);
if (!highlighted) {
String out = NLS.bind(ConsoleTestMessages.OpenMappingFileTest_highlighted_region_for_property_is_empty_package, new Object[] { compositeProperty.getName(), testPackage.getElementName() });
if (Customization.USE_CONSOLE_OUTPUT)
System.err.println(out);
fail(out);
}
Object[] compProperties = propertyWorkbenchAdapter.getChildren(compositeProperty);
for (int k = 0; k < compProperties.length; k++) {
// test Composite properties
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(ConsoleTestMessages.OpenMappingFileTest_mapping_file_for_property_not_opened_package, new Object[] { compositeProperty.getName(), testPackage.getElementName(), ex.getMessage() });
fail(out);
}
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class OpenSourceFileTest method testOpenSourceFileTest.
public void testOpenSourceFileTest() {
// fail("test fail");
final Object[] persClasses = getPersistenceClasses(false);
final ConsoleConfiguration consCFG = getConsoleConfig();
for (int i = 0; i < persClasses.length; i++) {
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
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationTest method testHQLListParameters.
@Test
public void testHQLListParameters() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
// fix for https://issues.jboss.org/browse/JBIDE-9392
// the view calls jdbc connection
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView(QueryPageTabView.ID);
if (view != null) {
activePage.hideView(view);
view.dispose();
}
consoleCfg.build();
IConfiguration c = consoleCfg.getConfiguration();
IPersistentClass rc = service.newRootClass();
rc.setEntityName("java.awt.Button");
rc.setClassName("java.awt.Button");
IColumn column = service.newColumn("label");
ITable table = service.newTable("faketable");
IPrimaryKey pk = table.getPrimaryKey();
pk.addColumn(column);
rc.setTable(table);
table.addColumn(column);
IProperty fakeProp = service.newProperty();
fakeProp.setName("label");
IValue sv = service.newSimpleValue();
sv.addColumn(column);
sv.setTypeName("string");
sv.setTable(table);
fakeProp.setValue(sv);
rc.setIdentifierProperty(fakeProp);
rc.setIdentifier(fakeProp.getValue());
c.addClass(rc);
consoleCfg.buildSessionFactory();
ConsoleQueryParameter paramA = new ConsoleQueryParameter(service, "a", typeFactory.getIntegerType(), new Integer[] { new Integer(1), new Integer(2) });
ConsoleQueryParameter paramB = new ConsoleQueryParameter(service, "b", typeFactory.getIntegerType(), new Integer(3));
ConsoleQueryParameter paramOrdered = new ConsoleQueryParameter(service, "0", typeFactory.getIntegerType(), new Integer(4));
QueryInputModel model = new QueryInputModel(service);
model.addParameter(paramA);
model.addParameter(paramB);
model.addParameter(paramOrdered);
// $NON-NLS-1$
QueryPage qp = consoleCfg.executeHQLQuery("select count(*) from java.awt.Button where 1 in ( ?, :a, :b )", model);
Assert.assertNotNull(qp);
try {
// execute the query
qp.getList();
} catch (Exception e) {
// ignore - there is fake mapping
}
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class MappingTestHelper 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
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class MappingTestHelper method openPropertyTest.
private void openPropertyTest(IProperty compositeProperty, IProperty parentProperty, ConsoleConfiguration consCFG) {
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);
}
}
Aggregations