use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewMap.
@Test
public void testNewMap() {
IPersistentClass persistentClass = service.newRootClass();
IValue map = service.newMap(persistentClass);
Assert.assertNotNull(map);
Object target = ((IFacade) map).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof Map);
}
use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewArtifactCollector.
@Test
public void testNewArtifactCollector() {
IArtifactCollector artifactCollector = service.newArtifactCollector();
Assert.assertNotNull(artifactCollector);
Object target = ((IFacade) artifactCollector).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof ArtifactCollector);
}
use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewSet.
@Test
public void testNewSet() {
IPersistentClass persistentClass = service.newRootClass();
IValue set = service.newSet(persistentClass);
Assert.assertNotNull(set);
Object target = ((IFacade) set).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof Set);
}
use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewSingleTableSubclass.
@Test
public void testNewSingleTableSubclass() {
IPersistentClass persistentClass = service.newRootClass();
IPersistentClass singleTableSublass = service.newSingleTableSubclass(persistentClass);
Assert.assertNotNull(singleTableSublass);
Object target = ((IFacade) singleTableSublass).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof SingleTableSubclass);
Assert.assertSame(persistentClass, singleTableSublass.getSuperclass());
Assert.assertSame(((IFacade) persistentClass).getTarget(), ((SingleTableSubclass) target).getSuperclass());
}
use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.
the class HibernateMappingExporterFacadeTest method testStart.
@Test
public void testStart() throws Exception {
MetadataDescriptor descriptor = new TestMetadataDescriptor();
hibernateMappingExporter.setMetadataDescriptor(descriptor);
hibernateMappingExporter.setOutputDirectory(outputDir);
final File fooHbmXml = new File(outputDir, "Foo.hbm.xml");
// First without a 'delegate' exporter
Assert.assertFalse(fooHbmXml.exists());
hibernateMappingExporterFacade.start();
Assert.assertTrue(fooHbmXml.exists());
Assert.assertTrue(fooHbmXml.delete());
// Now set a 'delegate' and invoke 'start' again
final File dummyDir = new File(outputDir, "dummy");
dummyDir.mkdir();
Assert.assertTrue(dummyDir.exists());
IExportPOJODelegate delegate = new IExportPOJODelegate() {
@Override
public void exportPOJO(Map<Object, Object> map, IPOJOClass pojoClass) {
Assert.assertTrue(dummyDir.delete());
Map<String, Object> m = new HashMap<>();
for (Object key : map.keySet()) {
m.put((String) key, map.get(key));
}
hibernateMappingExporter.superExportPOJO(m, (POJOClass) ((IFacade) pojoClass).getTarget());
}
};
Field delegateField = HibernateMappingExporterExtension.class.getDeclaredField("delegateExporter");
delegateField.setAccessible(true);
delegateField.set(hibernateMappingExporter, delegate);
hibernateMappingExporterFacade.start();
Assert.assertFalse(dummyDir.exists());
Assert.assertTrue(fooHbmXml.exists());
Assert.assertTrue(fooHbmXml.delete());
Assert.assertTrue(outputDir.exists());
}
Aggregations