Author: epbernard
Date: 2009-08-09 23:59:59 -0400 (Sun, 09 Aug 2009)
New Revision: 17255
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/FoodItem.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/Fridge.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
Log:
EJB-456 start core of tests
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/FoodItem.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/FoodItem.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/FoodItem.java 2009-08-10
03:59:59 UTC (rev 17255)
@@ -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;
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/Fridge.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/Fridge.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/Fridge.java 2009-08-10
03:59:59 UTC (rev 17255)
@@ -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;
+ }
+}
+
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java 2009-08-10
03:59:59 UTC (rev 17255)
@@ -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
+ };
+ }
+
+}
Show replies by date