Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.j256.ormlite.table;
 
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 
public class TableInfoTest extends BaseOrmLiteTest {

Test to make sure that we can call a private constructor
	public void testPrivateConstructor() throws Exception {
		Dao<PrivateConstructorObjectpackConstDao = createDao(PrivateConstructor.classtrue);
		int id = 12312321;
		PrivateConstructor pack1 = PrivateConstructor.makeOne(id);
		assertEquals(idpack1.id);
		packConstDao.create(pack1);
		// we should be able to look it up
		PrivateConstructor pack2 = packConstDao.queryForId(id);
		// and the id should match
		assertEquals(idpack2.id);
	}
	private static class PrivateConstructor {
		@DatabaseField(id = true)
		int id;
		private PrivateConstructor() {
			// make it private
		}
		public static PrivateConstructor makeOne(int id) {
			pack.id = id;
			return pack;
		}
	}
New to GrepCode? Check out our FAQ X