Search in sources :

Example 1 with DelegatingStrategy

use of org.hibernate.tool.internal.reveng.strategy.DelegatingStrategy in project jbosstools-hibernate by jbosstools.

the class OverrideRepositoryFacadeTest method testGetReverseEngineeringStrategy.

@Test
public void testGetReverseEngineeringStrategy() throws Exception {
    RevengStrategy res = new DefaultStrategy();
    IReverseEngineeringStrategy resFacade = FACADE_FACTORY.createReverseEngineeringStrategy(res);
    IReverseEngineeringStrategy result = overrideRepositoryFacade.getReverseEngineeringStrategy(resFacade);
    DelegatingStrategy resultTarget = (DelegatingStrategy) ((IFacade) result).getTarget();
    Field delegateField = DelegatingStrategy.class.getDeclaredField("delegate");
    delegateField.setAccessible(true);
    assertSame(res, delegateField.get(resultTarget));
}
Also used : Field(java.lang.reflect.Field) RevengStrategy(org.hibernate.tool.api.reveng.RevengStrategy) IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) DelegatingStrategy(org.hibernate.tool.internal.reveng.strategy.DelegatingStrategy) DefaultStrategy(org.hibernate.tool.internal.reveng.strategy.DefaultStrategy) Test(org.junit.jupiter.api.Test)

Example 2 with DelegatingStrategy

use of org.hibernate.tool.internal.reveng.strategy.DelegatingStrategy in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewReverseEngineeringStrategy.

@Test
public void testNewReverseEngineeringStrategy() throws Exception {
    IReverseEngineeringStrategy defaultStrategy = service.newDefaultReverseEngineeringStrategy();
    IReverseEngineeringStrategy newStrategy = service.newReverseEngineeringStrategy(DefaultStrategy.class.getName(), defaultStrategy);
    assertNotNull(newStrategy);
    Object target = ((IFacade) newStrategy).getTarget();
    assertNotNull(target);
    assertFalse(target instanceof DelegatingStrategy);
    newStrategy = service.newReverseEngineeringStrategy(DelegatingStrategy.class.getName(), defaultStrategy);
    assertNotNull(newStrategy);
    target = ((IFacade) newStrategy).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof DelegatingStrategy);
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) DelegatingStrategy(org.hibernate.tool.internal.reveng.strategy.DelegatingStrategy) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) DefaultStrategy(org.hibernate.tool.internal.reveng.strategy.DefaultStrategy) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultStrategy (org.hibernate.tool.internal.reveng.strategy.DefaultStrategy)2 DelegatingStrategy (org.hibernate.tool.internal.reveng.strategy.DelegatingStrategy)2 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)2 Test (org.junit.jupiter.api.Test)2 Field (java.lang.reflect.Field)1 RevengStrategy (org.hibernate.tool.api.reveng.RevengStrategy)1 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)1