package org.dynamicfinder.test.unit.jpa;

import org.dynamicfinder.QueryBuilder;
import org.dynamicfinder.jpa.JpaQueryBuilder;
import org.dynamicfinder.test._entity.Person;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author xsalefter (xsalefter[at]gmail.com)
 */
public class JpaQueryBuilderTest {

	private static Logger logger = LoggerFactory.getLogger(JpaQueryBuilderTest.class);

	@Test
	public void constructor() {
		logger.debug("#constructor()");

		QueryBuilder queryBuilder = new JpaQueryBuilder(Person.class);

		Assert.assertNotNull(queryBuilder);
		Assert.assertNotNull(queryBuilder.getActualRestrictions());
		Assert.assertEquals(0, queryBuilder.getActualRestrictions().size());
		Assert.assertEquals(queryBuilder.getQueryString().trim(), "select person from Person person");
	}

}

@@ -103,16 +103,24 @@
 der.jpa.
+Abstract
 JpaQuery
@@ -120,32 +120,122 @@
 paQueryBuilder;%0A
+import org.dynamicfinder.jpa.JpaQueryBuilder;%0Aimport org.dynamicfinder.test._entity.City;%0A
 import org.dynam
@@ -954,10 +954,342 @@
 %22);%0A%09%7D%0A%0A
+%0A%09/**%0A%09 * Test whether %7B@link AbstractJpaQueryBuilder#createEntityAndAliasNameFromClass(Class)%7D %0A%09 * is ok.%0A%09 */%0A%09@Test%0A%09public void readNameMemberOnEntityTest() %7B%0A%09%09QueryBuilder queryBuilder = new JpaQueryBuilder(City.class);%0A%09%09Assert.assertEquals(queryBuilder.getQueryString(), %22select cityEntity from CityEntity cityEntity%22);%0A%09%7D%0A
 %7D%0A

Add test for @Entity(name="somename")