Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.j256.ormlite.field.types;
 
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
public class DateTimeTypeTest extends BaseCoreTest {
	public void testJavaToSqlArg() throws Exception {
		DateTime dateTime = new DateTime();
		assertEquals(dateTime.getMillis(), DateTimeType.getSingleton().javaToSqlArg(nulldateTime));
	}
	public void testParseDefaultString() {
		Long value = 423424234234L;
		assertEquals(value, DateTimeType.getSingleton().parseDefaultString(nullvalue.toString()));
	}
	public void testResultToSqlArg() throws Exception {
		int col = 21;
		long value = 2094234324L;
		expect(results.getLong(col)).andReturn(value);
		replay(results);
		assertEquals(new DateTime(value), DateTimeType.getSingleton().resultToJava(nullresultscol));
	}
	public void testPersist() throws Exception {
		Dao<StoreDateTimeObjectdao = createDao(StoreDateTime.classtrue);
		StoreDateTime foo = new StoreDateTime();
		foo.dateTime = new DateTime();
		assertEquals(1, dao.create(foo));
		StoreDateTime result = dao.queryForId(foo.id);
		assertEquals(result.dateTimefoo.dateTime);
	}
	private static class StoreDateTime {
		@DatabaseField(generatedId = true)
		int id;
		public StoreDateTime() {
		}
	}
New to GrepCode? Check out our FAQ X