EJB-456 start core of tests
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17255 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
0d14085ba6
commit
174d09e34b
|
@ -0,0 +1,31 @@
|
|||
package org.hibernate.ejb.test.metadata;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class FoodItem {
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
@Id @GeneratedValue
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package org.hibernate.ejb.test.metadata;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class Fridge {
|
||||
private Long id;
|
||||
private String brand;
|
||||
private int temperature;
|
||||
//dimensions
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
public int getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(int temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package org.hibernate.ejb.test.metadata;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.metamodel.EntityType;
|
||||
import javax.persistence.metamodel.Bindable;
|
||||
import javax.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import org.hibernate.ejb.test.TestCase;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class MetadataTest extends TestCase {
|
||||
|
||||
public void testBaseOfService() throws Exception {
|
||||
EntityManagerFactory emf = factory;
|
||||
assertNotNull( emf.getMetamodel() );
|
||||
final EntityType<Fridge> entityType = emf.getMetamodel().entity( Fridge.class );
|
||||
assertNotNull( entityType );
|
||||
}
|
||||
|
||||
public void testBindable() throws Exception {
|
||||
EntityManagerFactory emf = factory;
|
||||
final EntityType<Fridge> entityType = emf.getMetamodel().entity( Fridge.class );
|
||||
assertEquals( Fridge.class, entityType.getBindableJavaType() );
|
||||
assertEquals( Bindable.BindableType.ENTITY_TYPE, entityType.getBindableType() );
|
||||
final SingularAttribute<? super Fridge,Integer> singularAttribute = entityType.getDeclaredSingularAttribute(
|
||||
"temperature",
|
||||
Integer.class
|
||||
);
|
||||
assertEquals( Integer.class, singularAttribute.getBindableJavaType() );
|
||||
assertEquals( Bindable.BindableType.SINGULAR_ATTRIBUTE, singularAttribute.getBindableType() );
|
||||
|
||||
//TODO test embedded
|
||||
//todo test plural
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getAnnotatedClasses() {
|
||||
return new Class[]{
|
||||
Fridge.class,
|
||||
FoodItem.class
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue