use of org.apache.tapestry5.hibernate.web.internal.SessionRestorable in project tapestry-5 by apache.
the class EntityPersistentFieldStrategyTest method transient_entity.
public void transient_entity() {
SampleEntity entity = new SampleEntity();
Session session = newMock(Session.class);
EntityPersistentFieldStrategy strategy = new EntityPersistentFieldStrategy(session, null);
expect(session.contains(entity)).andReturn(false);
replay();
Object persisted = strategy.convertApplicationValueToPersisted(entity);
assert persisted instanceof SessionRestorable;
Object restored = strategy.convertPersistedToApplicationValue(persisted);
assertSame(entity, restored);
verify();
}
use of org.apache.tapestry5.hibernate.web.internal.SessionRestorable in project tapestry-5 by apache.
the class EntityPersistentFieldStrategyTest method persistent_entity.
public void persistent_entity() {
SampleEntity entity = new SampleEntity();
SampleEntity restoredEntity = new SampleEntity();
Session session = newMock(Session.class);
EntityPersistentFieldStrategy strategy = new EntityPersistentFieldStrategy(session, null);
expect(session.contains(entity)).andReturn(true);
expect(session.getEntityName(entity)).andReturn("SampleEntity");
expect(session.getIdentifier(entity)).andReturn(42);
expect(session.get("SampleEntity", 42)).andReturn(restoredEntity);
replay();
Object persisted = strategy.convertApplicationValueToPersisted(entity);
assert persisted instanceof SessionRestorable;
Object restored = strategy.convertPersistedToApplicationValue(persisted);
assertSame(restored, restoredEntity);
verify();
}
Aggregations