// Path: try_java_ee7-web/src/main/java/enterprisegeeks/entity/Room.java
// @Vetoed //CDI対象外
// @XmlRootElement
// @Entity
// @NamedQueries(@NamedQuery(name = "Room.all", query = "select r from Room r order by r.id"))
// public class Room implements Serializable {
//     
//     /** id(自動生成) */
//     @Id
//     @GeneratedValue
//     private long id;
//     
//     /** 部屋名 */
//     @Column(nullable = false, length = 40, unique = true)
//     private String name;
// 
//     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;
//     }
//     
//     
// }
// 
// Path: try_java_ee7-web/src/test/java/util/PrivateUtil.java
// public class PrivateUtil {
//     public static void setField(Object instance, String name, Object obj) {
//         
//         try {
//             Field f = instance.getClass().getDeclaredField(name);
//             f.setAccessible(true);
//             f.set(instance, obj);
//         } catch (NoSuchFieldException | IllegalArgumentException  | IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
//     
//     public static <T> T getFiled(Object obj, String name, Class<T> clazz) {
//         try {
//             Field f = obj.getClass().getDeclaredField(name);
//             f.setAccessible(true);
//             return (T)f.get(obj);
//         } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
// }


import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import enterprisegeeks.entity.Room;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import util.PrivateUtil;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package enterprisegeeks.service;


/**
 * Serviceのテスト
 * EntityManagerへの依存性を自力で解消する方法
 */
public class ServiceTest {
    
    @BeforeClass
    public static void setUpClass() {

    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    private Service target;
    private EntityManager em;
    private EntityTransaction tx;
    
    @Before
    public void setUp() throws Exception{
        em = Persistence.createEntityManagerFactory("stand_alone").createEntityManager();
        target = new ServiceImpl();
// Path: try_java_ee7-web/src/main/java/enterprisegeeks/entity/Room.java
// @Vetoed //CDI対象外
// @XmlRootElement
// @Entity
// @NamedQueries(@NamedQuery(name = "Room.all", query = "select r from Room r order by r.id"))
// public class Room implements Serializable {
//     
//     /** id(自動生成) */
//     @Id
//     @GeneratedValue
//     private long id;
//     
//     /** 部屋名 */
//     @Column(nullable = false, length = 40, unique = true)
//     private String name;
// 
//     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;
//     }
//     
//     
// }
// 
// Path: try_java_ee7-web/src/test/java/util/PrivateUtil.java
// public class PrivateUtil {
//     public static void setField(Object instance, String name, Object obj) {
//         
//         try {
//             Field f = instance.getClass().getDeclaredField(name);
//             f.setAccessible(true);
//             f.set(instance, obj);
//         } catch (NoSuchFieldException | IllegalArgumentException  | IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
//     
//     public static <T> T getFiled(Object obj, String name, Class<T> clazz) {
//         try {
//             Field f = obj.getClass().getDeclaredField(name);
//             f.setAccessible(true);
//             return (T)f.get(obj);
//         } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
// }


// Path: try_java_ee7-web/src/test/java/enterprisegeeks/service/ServiceTest.java
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import enterprisegeeks.entity.Room;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import util.PrivateUtil;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package enterprisegeeks.service;


/**
 * Serviceのテスト
 * EntityManagerへの依存性を自力で解消する方法
 */
public class ServiceTest {
    
    @BeforeClass
    public static void setUpClass() {

    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    private Service target;
    private EntityManager em;
    private EntityTransaction tx;
    
    @Before
    public void setUp() throws Exception{
        em = Persistence.createEntityManagerFactory("stand_alone").createEntityManager();
        target = new ServiceImpl();
        PrivateUtil.setField(target, "em", em);