// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/DbQuerydslTestModule.java
// public class DbQuerydslTestModule extends AbstractModule {
// 
// 	@Override
// 	protected void configure() {
// 		install(new GuiceConfModule());
// 		install(new DataSourceModule());
// 		install(new GuiceDbTestModule());
// 	}
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/db/User.java
// @Generated("com.coreoz.plume.db.querydsl.generation.IdBeanSerializer")
// public class User extends com.coreoz.plume.db.querydsl.crud.CrudEntityQuerydsl {
// 
//     @Column("ACTIVE")
//     private Boolean active;
// 
//     @Column("CREATION_DATE")
//     private java.time.LocalDateTime creationDate;
// 
//     @Column("ID")
//     private Long id;
// 
//     @Column("NAME")
//     private String name;
// 
//     public Boolean getActive() {
//         return active;
//     }
// 
//     public void setActive(Boolean active) {
//         this.active = active;
//     }
// 
//     public java.time.LocalDateTime getCreationDate() {
//         return creationDate;
//     }
// 
//     public void setCreationDate(java.time.LocalDateTime creationDate) {
//         this.creationDate = creationDate;
//     }
// 
//     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;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (id == null) {
//             return super.equals(o);
//         }
//         if (!(o instanceof User)) {
//             return false;
//         }
//         User obj = (User) o;
//         return id.equals(obj.id);
//     }
// 
//     @Override
//     public int hashCode() {
//         if (id == null) {
//             return super.hashCode();
//         }
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + id.hashCode();
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return "User#" + id;
//     }
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/db/UserDao.java
// @Singleton
// public class UserDao extends CrudDaoQuerydsl<User> {
// 
// 	@Inject
// 	public UserDao(TransactionManagerQuerydsl transactionManagerQuerydsl) {
// 		super(transactionManagerQuerydsl, QUser.user);
// 	}
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/transaction/TransactionInstancesHolder.java
// public class TransactionInstancesHolder {
// 
// 	private DataSourceMocked mockedDataSource;
// 	private ConnectionMocked mockedConnection;
// 	private TransactionManagerQuerydsl transactionManager;
// 
// 	public TransactionInstancesHolder(DataSource realDataSource) {
// 		try {
// 			Connection realConnection = realDataSource.getConnection();
// 			mockedConnection = new ConnectionMocked(realConnection);
// 			mockedDataSource = new DataSourceMocked(mockedConnection);
// 
// 			transactionManager = new TransactionManagerQuerydsl(
// 				mockedDataSource,
// 				new Configuration(H2Templates.DEFAULT)
// 			);
// 		} catch (SQLException e) {
// 			throw new RuntimeException(e);
// 		}
// 	}
// 
// 	public DataSourceMocked getMockedDataSource() {
// 		return mockedDataSource;
// 	}
// 
// 	public ConnectionMocked getMockedConnection() {
// 		return mockedConnection;
// 	}
// 
// 	public TransactionManagerQuerydsl getTransactionManager() {
// 		return transactionManager;
// 	}
// 
// }


import static org.assertj.core.api.Assertions.assertThat;
import java.sql.SQLException;
import javax.inject.Inject;
import javax.sql.DataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.carlosbecker.guice.GuiceModules;
import com.carlosbecker.guice.GuiceTestRunner;
import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.User;
import com.coreoz.plume.db.querydsl.db.UserDao;
import com.coreoz.plume.db.querydsl.transaction.TransactionInstancesHolder;

	@Test
	public void check_that_connection_is_NOT_released_after_transactional_save() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		User user = new User();
		user.setName("test");
		daoInstancesHolder.userDao.save(user, daoInstancesHolder.getMockedConnection());

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isFalse();
	}

	@Test
	public void check_that_connection_is_released_after_delete() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		daoInstancesHolder.userDao.delete(123132464L);

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isTrue();
	}

	@Test
	public void check_that_connection_is_NOT_released_after_transactional_delete() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		daoInstancesHolder.userDao.delete(123132464L, daoInstancesHolder.getMockedConnection());

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isFalse();
	}

// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/DbQuerydslTestModule.java
// public class DbQuerydslTestModule extends AbstractModule {
// 
// 	@Override
// 	protected void configure() {
// 		install(new GuiceConfModule());
// 		install(new DataSourceModule());
// 		install(new GuiceDbTestModule());
// 	}
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/db/User.java
// @Generated("com.coreoz.plume.db.querydsl.generation.IdBeanSerializer")
// public class User extends com.coreoz.plume.db.querydsl.crud.CrudEntityQuerydsl {
// 
//     @Column("ACTIVE")
//     private Boolean active;
// 
//     @Column("CREATION_DATE")
//     private java.time.LocalDateTime creationDate;
// 
//     @Column("ID")
//     private Long id;
// 
//     @Column("NAME")
//     private String name;
// 
//     public Boolean getActive() {
//         return active;
//     }
// 
//     public void setActive(Boolean active) {
//         this.active = active;
//     }
// 
//     public java.time.LocalDateTime getCreationDate() {
//         return creationDate;
//     }
// 
//     public void setCreationDate(java.time.LocalDateTime creationDate) {
//         this.creationDate = creationDate;
//     }
// 
//     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;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (id == null) {
//             return super.equals(o);
//         }
//         if (!(o instanceof User)) {
//             return false;
//         }
//         User obj = (User) o;
//         return id.equals(obj.id);
//     }
// 
//     @Override
//     public int hashCode() {
//         if (id == null) {
//             return super.hashCode();
//         }
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + id.hashCode();
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return "User#" + id;
//     }
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/db/UserDao.java
// @Singleton
// public class UserDao extends CrudDaoQuerydsl<User> {
// 
// 	@Inject
// 	public UserDao(TransactionManagerQuerydsl transactionManagerQuerydsl) {
// 		super(transactionManagerQuerydsl, QUser.user);
// 	}
// 
// }
// 
// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/transaction/TransactionInstancesHolder.java
// public class TransactionInstancesHolder {
// 
// 	private DataSourceMocked mockedDataSource;
// 	private ConnectionMocked mockedConnection;
// 	private TransactionManagerQuerydsl transactionManager;
// 
// 	public TransactionInstancesHolder(DataSource realDataSource) {
// 		try {
// 			Connection realConnection = realDataSource.getConnection();
// 			mockedConnection = new ConnectionMocked(realConnection);
// 			mockedDataSource = new DataSourceMocked(mockedConnection);
// 
// 			transactionManager = new TransactionManagerQuerydsl(
// 				mockedDataSource,
// 				new Configuration(H2Templates.DEFAULT)
// 			);
// 		} catch (SQLException e) {
// 			throw new RuntimeException(e);
// 		}
// 	}
// 
// 	public DataSourceMocked getMockedDataSource() {
// 		return mockedDataSource;
// 	}
// 
// 	public ConnectionMocked getMockedConnection() {
// 		return mockedConnection;
// 	}
// 
// 	public TransactionManagerQuerydsl getTransactionManager() {
// 		return transactionManager;
// 	}
// 
// }


// Path: plume-db-querydsl/src/test/java/com/coreoz/plume/db/querydsl/crud/CrudDaoQuerydslTransactionTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.sql.SQLException;
import javax.inject.Inject;
import javax.sql.DataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.carlosbecker.guice.GuiceModules;
import com.carlosbecker.guice.GuiceTestRunner;
import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.User;
import com.coreoz.plume.db.querydsl.db.UserDao;
import com.coreoz.plume.db.querydsl.transaction.TransactionInstancesHolder;


	@Test
	public void check_that_connection_is_NOT_released_after_transactional_save() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		User user = new User();
		user.setName("test");
		daoInstancesHolder.userDao.save(user, daoInstancesHolder.getMockedConnection());

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isFalse();
	}

	@Test
	public void check_that_connection_is_released_after_delete() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		daoInstancesHolder.userDao.delete(123132464L);

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isTrue();
	}

	@Test
	public void check_that_connection_is_NOT_released_after_transactional_delete() throws SQLException {
		DaoInstancesHolder daoInstancesHolder = new DaoInstancesHolder(dataSource);

		daoInstancesHolder.userDao.delete(123132464L, daoInstancesHolder.getMockedConnection());

		assertThat(daoInstancesHolder.getMockedConnection().isCloseCalled()).isFalse();
	}

	private static class DaoInstancesHolder extends TransactionInstancesHolder {