use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method testGetJoinIterator.
@Test
public void testGetJoinIterator() throws Exception {
Join join = new Join();
Field field = AbstractPersistentClassFacade.class.getDeclaredField("joins");
field.setAccessible(true);
assertNull(field.get(persistentClassFacade));
Iterator<IJoin> joinIterator = persistentClassFacade.getJoinIterator();
assertNotNull(field.get(persistentClassFacade));
assertTrue(((HashSet<?>) field.get(persistentClassFacade)).isEmpty());
assertFalse(joinIterator.hasNext());
field.set(persistentClassFacade, null);
((RootClass) persistentClassTarget).addJoin(join);
joinIterator = persistentClassFacade.getJoinIterator();
assertTrue(joinIterator.hasNext());
assertSame(join, ((IFacade) joinIterator.next()).getTarget());
assertFalse(joinIterator.hasNext());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method testIsAssignableToRootClass.
@Test
public void testIsAssignableToRootClass() {
persistentClassTarget = new SingleTableSubclass(new RootClass());
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
assertFalse(persistentClassFacade.isAssignableToRootClass());
persistentClassTarget = new RootClass();
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
assertTrue(persistentClassFacade.isAssignableToRootClass());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method beforeEach.
@BeforeEach
public void beforeEach() {
persistentClassTarget = new RootClass();
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method testGetPropertyClosureIterator.
@Test
public void testGetPropertyClosureIterator() throws Exception {
Property propertyTarget = new Property();
PersistentClass persistentClass = new RootClass() {
private static final long serialVersionUID = 1L;
@Override
public Iterator<?> getPropertyClosureIterator() {
HashSet<Property> set = new HashSet<Property>();
set.add(propertyTarget);
return set.iterator();
}
};
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClass);
Field field = AbstractPersistentClassFacade.class.getDeclaredField("propertyClosures");
field.setAccessible(true);
assertNull(field.get(persistentClassFacade));
Iterator<IProperty> iterator = persistentClassFacade.getPropertyClosureIterator();
assertNotNull(field.get(persistentClassFacade));
assertTrue(iterator.hasNext());
assertSame(propertyTarget, ((IFacade) iterator.next()).getTarget());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method testGetDiscriminator.
@Test
public void testGetDiscriminator() throws Exception {
Value valueTarget = createValue();
Field field = AbstractPersistentClassFacade.class.getDeclaredField("discriminator");
field.setAccessible(true);
assertNull(field.get(persistentClassFacade));
assertNull(persistentClassFacade.getDiscriminator());
assertNull(field.get(persistentClassFacade));
((RootClass) persistentClassTarget).setDiscriminator(valueTarget);
IValue valueFacade = persistentClassFacade.getDiscriminator();
assertNotNull(valueFacade);
assertSame(valueFacade, field.get(persistentClassFacade));
assertSame(valueTarget, ((IFacade) valueFacade).getTarget());
}
Aggregations