// Path: src/test/java/com/itranswarp/warpdb/test/Address.java
// public class Address {
// 
// 	public final String city;
// 	public final String street;
// 	public final String zip;
// 
// 	public Address(String city, String street, String zip) {
// 		this.city = city;
// 		this.street = street;
// 		this.zip = zip;
// 	}
// }
// 
// Path: src/test/java/com/itranswarp/warpdb/test/TodoEntity.java
// @Entity
// @Table(name = "todos")
// public class TodoEntity extends BaseEntity {
// 
// 	@Column(name = "f_name", length = 100)
// 	public String name;
// 
// 	@Convert(converter = LocalDateConverter.class)
// 	@Column(name = "f_Target_date", columnDefinition = "date")
// 	public LocalDate targetDate;
// 
// 	@Convert(converter = LocalDateTimeConverter.class)
// 	@Column(columnDefinition = "datetime")
// 	public LocalDateTime targetDateTime;
// 
// 	@Convert(converter = AddressConverter.class)
// 	@Column(columnDefinition = "varchar(100)")
// 	public Address address;
// }


import static org.junit.Assert.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import org.junit.Test;
import com.itranswarp.warpdb.test.Address;
import com.itranswarp.warpdb.test.TodoEntity;
package com.itranswarp.warpdb;





public class WarpDbConverterTest extends WarpDbTestBase {

	@Test
	public void testConvert() throws Exception {
		TodoEntity todo = new TodoEntity();
		todo.id = TodoEntity.nextId();
		todo.name = "Unit Test";
		todo.targetDate = LocalDate.of(2016, 10, 20);
		todo.targetDateTime = LocalDateTime.of(2016, 10, 20, 11, 12, 13);
		todo.address = new Address("Beijing", "No.1 Road", "100101");
		warpdb.insert(todo);
		// query:
		TodoEntity bak = warpdb.fetch(TodoEntity.class, todo.id);
		assertNotNull(bak);
		Address addr = bak.address;
		assertNotNull(addr);
		assertEquals("Beijing", addr.city);
		assertEquals("No.1 Road", addr.street);
		assertEquals("100101", addr.zip);
		// update:
		bak.address = new Address("Shanghai", "#1 Street", "200202");
		warpdb.update(bak);
		// query:
		TodoEntity bak2 = warpdb.fetch(TodoEntity.class, todo.id);
		assertNotNull(bak2);
// Path: src/test/java/com/itranswarp/warpdb/test/Address.java
// public class Address {
// 
// 	public final String city;
// 	public final String street;
// 	public final String zip;
// 
// 	public Address(String city, String street, String zip) {
// 		this.city = city;
// 		this.street = street;
// 		this.zip = zip;
// 	}
// }
// 
// Path: src/test/java/com/itranswarp/warpdb/test/TodoEntity.java
// @Entity
// @Table(name = "todos")
// public class TodoEntity extends BaseEntity {
// 
// 	@Column(name = "f_name", length = 100)
// 	public String name;
// 
// 	@Convert(converter = LocalDateConverter.class)
// 	@Column(name = "f_Target_date", columnDefinition = "date")
// 	public LocalDate targetDate;
// 
// 	@Convert(converter = LocalDateTimeConverter.class)
// 	@Column(columnDefinition = "datetime")
// 	public LocalDateTime targetDateTime;
// 
// 	@Convert(converter = AddressConverter.class)
// 	@Column(columnDefinition = "varchar(100)")
// 	public Address address;
// }


// Path: src/test/java/com/itranswarp/warpdb/WarpDbConverterTest.java
import static org.junit.Assert.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import org.junit.Test;
import com.itranswarp.warpdb.test.Address;
import com.itranswarp.warpdb.test.TodoEntity;

package com.itranswarp.warpdb;





public class WarpDbConverterTest extends WarpDbTestBase {

	@Test
	public void testConvert() throws Exception {
		TodoEntity todo = new TodoEntity();
		todo.id = TodoEntity.nextId();
		todo.name = "Unit Test";
		todo.targetDate = LocalDate.of(2016, 10, 20);
		todo.targetDateTime = LocalDateTime.of(2016, 10, 20, 11, 12, 13);
		todo.address = new Address("Beijing", "No.1 Road", "100101");
		warpdb.insert(todo);
		// query:
		TodoEntity bak = warpdb.fetch(TodoEntity.class, todo.id);
		assertNotNull(bak);
		Address addr = bak.address;
		assertNotNull(addr);
		assertEquals("Beijing", addr.city);
		assertEquals("No.1 Road", addr.street);
		assertEquals("100101", addr.zip);
		// update:
		bak.address = new Address("Shanghai", "#1 Street", "200202");
		warpdb.update(bak);
		// query:
		TodoEntity bak2 = warpdb.fetch(TodoEntity.class, todo.id);
		assertNotNull(bak2);
		Address addr2 = bak2.address;