Search in sources :

Example 41 with KeyValue

use of org.hibernate.mapping.KeyValue in project jbosstools-hibernate by jbosstools.

the class PersistentClassFacadeTest method testGetIdentifier.

@Test
public void testGetIdentifier() throws Exception {
    KeyValue valueTarget = createValue();
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("identifier");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    assertNull(persistentClassFacade.getIdentifier());
    assertNull(field.get(persistentClassFacade));
    ((RootClass) persistentClassTarget).setIdentifier(valueTarget);
    IValue valueFacade = persistentClassFacade.getIdentifier();
    assertNotNull(valueFacade);
    assertSame(valueFacade, field.get(persistentClassFacade));
    assertSame(valueTarget, ((IFacade) valueFacade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) KeyValue(org.hibernate.mapping.KeyValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Test(org.junit.jupiter.api.Test)

Example 42 with KeyValue

use of org.hibernate.mapping.KeyValue in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testSetKey.

@Test
public void testSetKey() {
    KeyValue keyValueTarget = new SimpleValue(null);
    IValue keyValueFacade = FACADE_FACTORY.createValue(keyValueTarget);
    Collection collectionTarget = new Bag(null, null);
    IValue collectionFacade = FACADE_FACTORY.createValue(collectionTarget);
    assertNull(collectionTarget.getKey());
    collectionFacade.setKey(keyValueFacade);
    assertSame(keyValueTarget, collectionTarget.getKey());
}
Also used : KeyValue(org.hibernate.mapping.KeyValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Collection(org.hibernate.mapping.Collection) Bag(org.hibernate.mapping.Bag) IdentifierBag(org.hibernate.mapping.IdentifierBag) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.jupiter.api.Test)

Example 43 with KeyValue

use of org.hibernate.mapping.KeyValue in project jbosstools-hibernate by jbosstools.

the class PersistentClassFacadeTest method testGetIdentifier.

@Test
public void testGetIdentifier() throws Exception {
    KeyValue valueTarget = createValue();
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("identifier");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    assertNull(persistentClassFacade.getIdentifier());
    assertNull(field.get(persistentClassFacade));
    ((RootClass) persistentClassTarget).setIdentifier(valueTarget);
    IValue valueFacade = persistentClassFacade.getIdentifier();
    assertNotNull(valueFacade);
    assertSame(valueFacade, field.get(persistentClassFacade));
    assertSame(valueTarget, ((IFacade) valueFacade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) KeyValue(org.hibernate.mapping.KeyValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Test(org.junit.jupiter.api.Test)

Example 44 with KeyValue

use of org.hibernate.mapping.KeyValue in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testSetKey.

@Test
public void testSetKey() {
    KeyValue keyValueTarget = new SimpleValue(null);
    IValue keyValueFacade = FACADE_FACTORY.createValue(keyValueTarget);
    Collection collectionTarget = new Bag(null, null);
    IValue collectionFacade = FACADE_FACTORY.createValue(collectionTarget);
    assertNull(collectionTarget.getKey());
    collectionFacade.setKey(keyValueFacade);
    assertSame(keyValueTarget, collectionTarget.getKey());
}
Also used : KeyValue(org.hibernate.mapping.KeyValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Collection(org.hibernate.mapping.Collection) Bag(org.hibernate.mapping.Bag) IdentifierBag(org.hibernate.mapping.IdentifierBag) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.jupiter.api.Test)

Example 45 with KeyValue

use of org.hibernate.mapping.KeyValue in project jbosstools-hibernate by jbosstools.

the class TableFacadeTest method testGetIdentifierValue.

@Test
public void testGetIdentifierValue() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    IValue valueFacade = tableFacade.getIdentifierValue();
    assertNull(valueFacade);
    KeyValue value = new SimpleValue(DummyMetadataBuildingContext.INSTANCE, null);
    table.setIdentifierValue(value);
    valueFacade = tableFacade.getIdentifierValue();
    assertSame(value, ((IFacade) valueFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) KeyValue(org.hibernate.mapping.KeyValue) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.jupiter.api.Test)

Aggregations

KeyValue (org.hibernate.mapping.KeyValue)53 Test (org.junit.jupiter.api.Test)44 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)35 SimpleValue (org.hibernate.mapping.SimpleValue)33 Collection (org.hibernate.mapping.Collection)13 Bag (org.hibernate.mapping.Bag)12 IdentifierBag (org.hibernate.mapping.IdentifierBag)12 Map (org.hibernate.mapping.Map)12 Table (org.hibernate.mapping.Table)12 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)12 Field (java.lang.reflect.Field)11 RootClass (org.hibernate.mapping.RootClass)11 Iterator (java.util.Iterator)3 BasicValue (org.hibernate.mapping.BasicValue)3 Test (org.junit.Test)3 JoinColumn (javax.persistence.JoinColumn)2 Ejb3JoinColumn (org.hibernate.cfg.Ejb3JoinColumn)2 Property (org.hibernate.mapping.Property)2 AbstractValueFacade (org.jboss.tools.hibernate.runtime.common.AbstractValueFacade)2 ArrayList (java.util.ArrayList)1