/**
* @Created Sep 16, 2010 9:04:00 AM
* @author cry30
*/
package com.philip.journal.core.dao.spring.hibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.NonUniqueResultException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.philip.journal.core.Constant;
import com.philip.journal.core.JournalTestCommon;
import com.philip.journal.core.dao.BaseJournalTestDAO;
import com.philip.journal.core.dao.DaoConstant;
import com.philip.journal.core.exception.JournalException;
import com.philip.journal.home.bean.Branch;
import com.philip.journal.home.bean.Entry;
import com.philip.journal.home.dao.BranchDAO;
import com.philip.journal.home.dao.EntryDAO;
/**
* This class requires UserDAO, EntryDAO, BranchDAO.
*/
public class BaseDAOSpringHibernateEntryTest extends BaseJournalTestDAO {
@Override
protected String getTestSqlPath()
{
return "/com/philip/journal/core/dao/spring/hibernate/BaseDAOSpringHibernateTest.sql";
}
/** RTFC. */
private static final int TEST_INT = 667;
/** IOC wired Entry DAO. */
@Autowired
private transient EntryDAO entryDAO;
/** IOC wired Branch DAO. */
@Autowired
private transient BranchDAO branchDAO;
/** Branch Id attribute. */
private static final String ATTR_BRANCH_ID = "branchId";
/** Entry title attribute. */
private static final String ATTR_ENTRY_TITLE = "title";
/** Entry description attribute. */
private static final String ATTR_ENTRY_DESC = "description";
/** Entry name attribute. */
private static final String ATTR_ENTRY_NAME = "name";
/** User username attribute. */
private static final String ATTR_USERNAME = "username";
/** User username attribute. */
private static final String ATTR_BRANCH = "branch";
//TEST ARTIFACTS=======================================================================
/** Test Artifact. Title. */
private static final String TEST_TITLE = "Test Title";
/** Reused constant. what ever. */
private static final String LEAF_ONE = "Leaf 1";
/** IOC wired target test instance. Wired an Entry in the config as of 10/26/2011 */
@Autowired
private transient BaseDAOSpringHibernate<Entry> testBaseSpringHibernateDAOEntryImpl; // NOPMD by r39 on 4/4/11 4:18 PM
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#deleteAll0(java.util.List)}.
*/
@Test(expected = JournalException.class)
public void testDeleteAllCase1()
{
testBaseSpringHibernateDAOEntryImpl.deleteAll0(null);
fail("Case 1: Null argument.");
}
/** Case 2: Null in list. */
@Test(expected = JournalException.class)
public void testDeleteAllCase2()
{
final List<Object> list1 = new ArrayList<Object>();
list1.add(null);
testBaseSpringHibernateDAOEntryImpl.deleteAll0(list1);
fail("null in List test failed.");
}
/**
* @exception JournalException expected due to deletion of constrained Entity.
*
* Case 3: Foreign key constraint.
*/
@Test(expected = JournalException.class)
public void testDeleteAllCase3()
{
final Branch branch2 = branchDAO.read(40002);
final List<Branch> list2 = new ArrayList<Branch>();
list2.add(branch2);
branchDAO.deleteAll(list2);
fail("Foreign key constraint test failed.");
}
/** Case 4: Expected behavior. */
@Test
public void testDeleteAllCase4()
{
final int count = super.getRecordCount(super.getBranchTableName());
final List<Branch> list3n4 = new ArrayList<Branch>();
getLogger().debug("branchDAO.read(ID_NOLEAF_BRANCH): " + branchDAO.read(ID_NOLEAF_BRANCH));
list3n4.add(branchDAO.read(ID_NOLEAF_BRANCH));
branchDAO.deleteAll(list3n4);
assertEquals("Count decrease check failed.", count - 1, super.getRecordCount(super.getBranchTableName()));
assertNull("Read deleted record check failed.", super.readBranch(ID_NOLEAF_BRANCH));
}
/** Case 5: Delete already deleted/missing object. */
@Test(expected = JournalException.class)
public void testDeleteAllCase5()
{
final List<Branch> list3n4 = new ArrayList<Branch>();
list3n4.add(branchDAO.read(ID_NOLEAF_BRANCH));
branchDAO.deleteAll(list3n4);
branchDAO.deleteAll(list3n4);
fail("Expected exception thrown check failed.");
}
/**
* Test method for {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAll0()}.
*
* Case 1: Read all.
*/
@Test
public void testReadAll1()
{
final List<?> list = testBaseSpringHibernateDAOEntryImpl.readAll0();
assertEquals("List size did not match", getRecordCount(super.getEntryTableName()), list.size());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAll0(java.lang.String, java.lang.Object)}
* .
*
* Case 1: Null property name.
*
*/
@Test(expected = JournalException.class)
public void testReadAll0StringObject1()
{
testBaseSpringHibernateDAOEntryImpl.readAll0(null, null);
fail("Expected exception throw check failed.");
}
/** Case 2: Invalid property name. */
@Test(expected = JournalException.class)
public void testReadAll0StringObject2()
{
testBaseSpringHibernateDAOEntryImpl.readAll0("Invalid", null);
fail("Expected exception on invalid property check failed.");
}
/** Case 3: Expected matched by ID. */
@Test
public void testReadAll0StringObject3()
{
assertEquals("Case 3: Expected matched by ID.", 1,
testBaseSpringHibernateDAOEntryImpl.readAll0(Entry.ID, ID_1ST_TST_BRANCH).size());
}
/** Case 4: Expected matched by title. */
@Test
public void testReadAll0StringObject4()
{
assertEquals("Title matched check failed.", 1,
testBaseSpringHibernateDAOEntryImpl.readAll0(ATTR_ENTRY_TITLE, LEAF_ONE).size());
}
/** Case 5: Expected matched by Create Date. */
@Test
public void testReadAll0StringObject5()
{
try {
final List<?> byDate = testBaseSpringHibernateDAOEntryImpl.readAll0("createDate",
new java.text.SimpleDateFormat("MMddyyyy").parse("06062006"));
assertEquals("Matched create date check failed.", COUNT_TEST_ENTRY, byDate.size());
} catch (final ParseException e) {
getCommon().failUnexpectedException(e);
}
}
/** Case 6: Expected matched by Create Time. */
@Test
public void testReadAll0StringObject6()
{
try {
final List<?> byTime = testBaseSpringHibernateDAOEntryImpl.readAll0("createTime",
new java.text.SimpleDateFormat("HHmmss").parse("060606"));
assertEquals("Matched create time check failed.", COUNT_TEST_ENTRY, byTime.size());
} catch (final ParseException e) {
getCommon().failUnexpectedException(e);
}
}
/** Case 7: Expected matched by Description. */
@Test
public void testReadAll0StringObject7()
{
final List<?> byDescription = testBaseSpringHibernateDAOEntryImpl.readAll0(ATTR_ENTRY_DESC,
"Great works are performed, not by strength, but by perseverance");
assertEquals("Description match check failed.", 1, byDescription.size());
}
/** Case 8: Expected mismatched by case sensitivity. */
@Test
public void testReadAll0StringObject8()
{
final List<?> byDescWrongCase = testBaseSpringHibernateDAOEntryImpl.readAll0(ATTR_ENTRY_DESC,
"great works are performed, not by strength, but by perseverance");
assertEquals("Case sensitive desc match check failed.", 0, byDescWrongCase.size());
}
/** Case 9: Expected matched Entity reference property. */
@Test
public void testReadAll0StringObject9()
{
final Branch branch = branchDAO.read(ID_1ST_TST_BRANCH);
assertEquals("Case 9: Expected matched Entity reference property.", 1, testBaseSpringHibernateDAOEntryImpl
.readAll0(ATTR_BRANCH, branch).size());
}
/** Case 10: Null property value. */
@Test
public void testReadAll0StringObject10()
{
assertEquals("Null property value check failed", 0, testBaseSpringHibernateDAOEntryImpl
.readAll0(Entry.ID, null).size());
getLogger().debug(testBaseSpringHibernateDAOEntryImpl.readAll0());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAll0(java.lang.String[])} .
*
* Case 1: Sort ascending.
*/
@Test
public void testReadAllStringArray1()
{
final List<Entry> sortByDescAsc = testBaseSpringHibernateDAOEntryImpl
.readAll0(new String[] { "description:asc" });
assertEquals("Case 1: Sort ascending failed", ID_FIRST_ASC, sortByDescAsc.get(0).getNodeId());
}
/** Case 2: Sort descending. */
@Test
public void testReadAllStringArray2()
{
final List<Entry> sortByTitleDesc = testBaseSpringHibernateDAOEntryImpl.readAll0(new String[] { "title:desc" });
assertEquals("Case 2: Sort descending.", ID_FIRST_DESC, sortByTitleDesc.get(0).getNodeId());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#delete(java.lang.Object)}.
*
* Case 1: Null argument.
*/
@Test(expected = JournalException.class)
public void testDelete1()
{
testBaseSpringHibernateDAOEntryImpl.delete(null);
}
/**
* Case 2: Non existing Entry.
*
* @exception JournalException Expected thrown exception.
*/
@Test(expected = JournalException.class)
public void testDelete2()
{
testBaseSpringHibernateDAOEntryImpl.delete(new Entry("Test", "Test", null));
fail("Case 2: Non existing Entry.");
}
/**
* Case 3.1: Expected null read after delete. <br/>
* Case 3.2: Expected record count after delete.
*/
@Test
public void testDelete3()
{
for (int i = 0; i < COUNT_TEST_ENTRY; i++) {
final Entry entry = entryDAO.read(ID_1ST_TST_BRANCH + i);
try {
testBaseSpringHibernateDAOEntryImpl.delete(entry);
} catch (final JournalException e) {
getCommon().failUnexpectedException(e);
}
assertNull("Case 3.1: Expected null read after delete: " + (i + 1), super.readEntry(entry.getNodeId()));
assertEquals("Case 3.2: Expected record count after delete: " + (i + 1), COUNT_TEST_ENTRY - 1 - i,
super.getRecordCount(super.getEntryTableName()));
}
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAll(java.util.Map)}.
*/
@Test
public void testReadAll()
{
super.clearEntryTable();
assertNotNull("1. Empty table test failed.", testBaseSpringHibernateDAOEntryImpl.readAll0());
assertEquals("1. Empty table test failed.", 0, testBaseSpringHibernateDAOEntryImpl.readAll0().size());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAllLike(java.util.Map)}.
*/
@Test
public void testReadAllLike()
{
String query = "%Not%";
final Map<String, String> map = new HashMap<String, String>();
map.put(ATTR_ENTRY_DESC, query);
List<Entry> list = testBaseSpringHibernateDAOEntryImpl.readAllLike(map);
assertEquals("1. Case mismatch test failed.", 0, list.size());
query = "%not%";
map.put(ATTR_ENTRY_DESC, query);
list = testBaseSpringHibernateDAOEntryImpl.readAllLike(map);
assertEquals("1. Case matched test failed.", 1, list.size());
}
/**
* Case 1: No space.
*
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAllIlike(java.util.Map)} .
*/
@Test
public void testReadAllIlikeCase1()
{
String query = "%Not%";
final Map<String, String> map = new HashMap<String, String>();
map.put(ATTR_ENTRY_DESC, query);
List<Entry> list = testBaseSpringHibernateDAOEntryImpl.readAllIlike(map);
assertEquals("1. Case mismatch test failed.", 1, list.size());
query = "%not%";
map.put(ATTR_ENTRY_DESC, query);
list = testBaseSpringHibernateDAOEntryImpl.readAllIlike(map);
assertEquals("1. Case matched test failed.", 1, list.size());
}
/** Case 2: With space. */
@Test
public void testReadAllIlikeCase2()
{
String query = "%nOt by sTrength%";
final Map<String, String> map = new HashMap<String, String>();
map.put(ATTR_ENTRY_DESC, query);
List<Entry> list = testBaseSpringHibernateDAOEntryImpl.readAllIlike(map);
assertEquals("1. Case mismatch test failed.", 1, list.size());
query = "%not%";
map.put(ATTR_ENTRY_DESC, query);
list = testBaseSpringHibernateDAOEntryImpl.readAllIlike(map);
assertEquals("1. Case matched test failed.", 1, list.size());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAllByParent(java.lang.String, java.lang.String, java.lang.Object)}
* .
*
* Case 1.1: Not found, non-null return.<br/>
* Case 1.2: Not found, empty List return.
*/
@Test
public void testReadAllByParent1()
{
final List<Entry> noMatch = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_BRANCH_ID,
ID_NON_EXISTENT);
assertNotNull("Case 1: Not found, non-null return.", noMatch);
assertEquals("Case 1.2: Not found, empty List return.", 0, noMatch.size());
}
/** Case 2: Matched Branch ID. */
@Test
public void testReadAllByParent2()
{
final List<Entry> byBranchId = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_BRANCH_ID,
ID_1ST_TST_BRANCH);
assertEquals("Case 2: Matched Branch ID.", 1, byBranchId.size());
}
/** Case 3: Matched Branch Name. */
@Test
public void testReadAllByParent3()
{
final List<Entry> byName = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_ENTRY_NAME,
"Test Branch 1");
assertEquals("Case 3: Matched Branch Name.", 1, byName.size());
}
/** Case 4: Matched by parent. */
@Test
public void testReadAllByParent4()
{
final Branch parent = branchDAO.read(Constant.ROOT_ID);
final List<Entry> byParent = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, "parent", parent);
assertEquals("Case 4: Matched by parent.", 2, byParent.size());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readAllByParent(java.lang.String, java.lang.String, java.lang.Object)}
* .
*/
@Test
public void testReadAllByParent()
{
final List<Entry> noMatch = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_BRANCH_ID,
40666L);
assertNotNull("1. Not Null check failed.", noMatch);
assertEquals("2. Empty list check failed.", 0, noMatch.size());
final List<Entry> byBranchId = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_BRANCH_ID,
40001L);
assertEquals("3. parent byBranchId check failed.", 1, byBranchId.size());
final List<Entry> byName = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, ATTR_ENTRY_NAME,
"Test Branch 1");
assertEquals("4. parent byName check failed.", 1, byName.size());
final Branch parent = branchDAO.read(Constant.ROOT_ID);
final List<Entry> byParent = testBaseSpringHibernateDAOEntryImpl.readAllByParent(ATTR_BRANCH, "parent", parent);
assertEquals("5. parent byParent check failed.", 2, byParent.size());
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readObject(java.util.Map)}.
*
* Case 1: Null argument.
*/
@Test(expected = JournalException.class)
public void testReadObjectMapOfStringObject1()
{
testBaseSpringHibernateDAOEntryImpl.readObject(null);
fail("Case 1: Null argument.");
}
/**
* Case 2.1: Multiple result on empty Map criteria. Case 2.2: Correct exception thrown.
*/
@Test
public void testReadObjectMapOfStringObject2()
{
try {
testBaseSpringHibernateDAOEntryImpl.readObject(new HashMap<String, Object>());
fail("Case 2.1: Empty criteria Map.");
} catch (final JournalException iae) {
assertTrue("Case 2.2: Correct exception thrown.", iae.getCause() instanceof NonUniqueResultException);
}
}
/** Case 3: Not matched. */
@Test
public void testReadObjectMapOfStringObject3()
{
final Map<String, Object> param = new HashMap<String, Object>();
param.put(Entry.ID, ID_1ST_TST_BRANCH);
param.put(ATTR_ENTRY_TITLE, "nomatch");
assertNull("Case 3: Not matched.", testBaseSpringHibernateDAOEntryImpl.readObject(param));
}
/** Case 4: Expected match on Entry ID and title. */
@Test
public void testReadObjectMapOfStringObject4()
{
final Map<String, Object> param = new HashMap<String, Object>();
param.put(Entry.ID, ID_1ST_TST_BRANCH);
param.put(ATTR_ENTRY_TITLE, LEAF_ONE);
assertNotNull("Case 4: Expected match on Entry ID and title.",
testBaseSpringHibernateDAOEntryImpl.readObject(param));
}
/** Case 5: Expected match on Description. */
@Test
public void testReadObjectMapOfStringObject5()
{
final Map<String, Object> param = new HashMap<String, Object>();
param.put(ATTR_ENTRY_DESC, "Great works are performed, not by strength, but by perseverance");
assertNotNull("Case 5: Expected match on Description.", testBaseSpringHibernateDAOEntryImpl.readObject(param));
}
/** Case 6: Expected match on Branch entity. */
@Test
public void testReadObjectMapOfStringObject6()
{
final Map<String, Object> param = new HashMap<String, Object>();
final Branch branch = branchDAO.read(ID_1ST_TST_BRANCH);
param.put(ATTR_BRANCH, branch);
assertNotNull("Case 6: Expected match on Branch entity.", testBaseSpringHibernateDAOEntryImpl.readObject(param));
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readObject(java.lang.String, java.util.Map)}
* .
*
* Case 1: Null named query argument.
*/
@Test(expected = JournalException.class)
public void testReadObjectStringMapOfStringObject1()
{
testBaseSpringHibernateDAOEntryImpl.readObject(null, new HashMap<String, Object>());
fail("Case 1: Null named query argument.");
}
/** Case 2: Non-existing named query. */
@Test(expected = JournalException.class)
public void testReadObjectStringMapOfStringObject2()
{
testBaseSpringHibernateDAOEntryImpl.readObject("Not exist", new HashMap<String, Object>());
fail("Case 2: Non-existing named query. ");
}
/** Case 3: Null map argument. */
@Test(expected = JournalException.class)
public void testReadObjectStringMapOfStringObject3()
{
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, (Map<String, Object>) null);
fail("Case 3: Null map argument.");
}
/** Case 4: Invalid property in Map parameter. */
@Test(expected = JournalException.class)
public void testReadObjectStringMapOfStringObject4()
{
final Map<String, Object> param4 = new HashMap<String, Object>();
param4.put("invalid", Integer.valueOf(TEST_INT));
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, param4);
fail("Case 4: Invalid property in Map parameter.");
}
/** Case 5: Null value in Map argument. */
@Test
public void testReadObjectStringMapOfStringObject5()
{
final Map<String, Object> param5 = new HashMap<String, Object>();
param5.put(ATTR_USERNAME, null);
assertNull("Case 5: Null value in Map argument. ",
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, param5));
}
/** Case 6: Mistyped param. */
@Test(expected = JournalException.class)
public void testReadObjectStringMapOfStringObject6()
{
final Map<String, Object> param6 = new HashMap<String, Object>();
param6.put(ATTR_USERNAME, new HashMap<String, Object>());
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, param6);
fail("Case 6: Mistyped param.");
}
/** Case 7: Unmatched. */
@Test
public void testReadObjectStringMapOfStringObject7()
{
final Map<String, Object> param7 = new HashMap<String, Object>();
param7.put(ATTR_USERNAME, "not found");
assertNull("Case 7: Unmatched.",
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, param7));
}
/** Case 8: Matched. */
@Test
public void testReadObjectStringMapOfStringObject8()
{
final Map<String, Object> param8 = new HashMap<String, Object>();
param8.put(ATTR_USERNAME, JournalTestCommon.TEST_USERNAME);
assertNotNull("Case 8: Matched.",
testBaseSpringHibernateDAOEntryImpl.readObject(DaoConstant.NamedQuery.BYUSERNAME, param8));
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readObject(java.lang.String, java.lang.Object)}
* .
*
* Case 1: Null property argument.
*/
@Test(expected = JournalException.class)
public void testReadObjectStringObject1()
{
testBaseSpringHibernateDAOEntryImpl.readObject((String) null, (Object) null);
fail("Case 1: Null property argument.");
}
/** Case 2: Illegal property. */
@Test(expected = JournalException.class)
public void testReadObjectStringObject2()
{
testBaseSpringHibernateDAOEntryImpl.readObject("wrong", (Object) null);
fail("Case 2: Illegal property.");
}
/** Case 3: Mistyped property value. */
@Test(expected = IllegalArgumentException.class)
public void testReadObjectStringObject3()
{
testBaseSpringHibernateDAOEntryImpl.readObject(Entry.ID, "Invalid Type");
fail("Case 3: Mistyped property value.");
}
/** Case 4: Non-existing bean. */
@Test
public void testReadObjectStringObject4()
{
assertNull("Case 4: Non-existing bean.",
testBaseSpringHibernateDAOEntryImpl.readObject(Entry.ID, ID_NON_EXISTENT));
}
/** Case 5: Expected existing bean. */
@Test
public void testReadObjectStringObject5()
{
assertNotNull("Case 5: Expected existing bean.",
testBaseSpringHibernateDAOEntryImpl.readObject(Entry.ID, ID_1ST_TST_BRANCH));
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#readObjectByParent(java.lang.String, java.lang.String, java.lang.Object, java.lang.String, java.lang.Object)}
* .
*
* Case 1: Null parent bean property.
*/
@Test(expected = JournalException.class)
public void testReadObjectByParent1()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent(null, "", "", "", "");
fail("Case 1: Null parent bean property.");
}
/** Case 2: Null parent property name. */
@Test(expected = JournalException.class)
public void testReadObjectByParent2()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent("", null, "", "", "");
fail("Case 2: Null parent property name.");
}
/** Case 3: Null bean property name. */
@Test(expected = JournalException.class)
public void testReadObjectByParent3()
{
testBaseSpringHibernateDAOEntryImpl
.readObjectByParent(ATTR_BRANCH, ATTR_BRANCH_ID, ID_1ST_TST_BRANCH, null, "");
fail("Case 3: Null bean property name.");
}
/** Case 4: Illegal parent bean property name. */
@Test(expected = JournalException.class)
public void testReadObjectByParent4()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent("branch666", ATTR_BRANCH_ID, ID_NON_EXISTENT,
ATTR_ENTRY_TITLE, TEST_TITLE);
fail("Case 4: Illegal parent bean property name.");
}
/** Case 5: Illegal parent bean property. */
@Test(expected = JournalException.class)
public void testReadObjectByParent5()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH, "branchId666", ID_NON_EXISTENT,
ATTR_ENTRY_TITLE, TEST_TITLE);
fail("Case 5: Illegal parent bean property.");
}
/** Case 6: Illegal bean property. */
@Test(expected = JournalException.class)
public void testReadObjectByParent6()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH, ATTR_BRANCH_ID, ID_NON_EXISTENT,
"title666", TEST_TITLE);
fail("Case 6: Illegal bean property.");
}
/** Case 7: Mistyped parent property value. */
@Test(expected = JournalException.class)
public void testReadObjectByParent7()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH, ATTR_BRANCH_ID, "Wrong type",
ATTR_ENTRY_TITLE, TEST_TITLE);
fail("Case 7: Mistyped parent property value.");
}
/** Case 8: Mistyped bean property value. */
@Test(expected = JournalException.class)
public void testReadObjectByParent8()
{
testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH, ATTR_BRANCH_ID, ID_NON_EXISTENT,
ATTR_ENTRY_TITLE, Integer.valueOf(TEST_INT));
fail("Case 8: Mistyped bean property value.");
}
/** Case 9: Unmatched parent. */
@Test
public void testReadObjectByParent9()
{
assertNull("Case 9: Unmatched parent.", testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH,
ATTR_BRANCH_ID, ID_NON_EXISTENT, ATTR_ENTRY_TITLE, LEAF_ONE));
}
/** Case 10: Unmatched bean value. */
@Test
public void testReadObjectByParent10()
{
assertNull("Case 10: Unmatched bean value.", testBaseSpringHibernateDAOEntryImpl.readObjectByParent(
ATTR_BRANCH, ATTR_BRANCH_ID, ID_1ST_TST_BRANCH, ATTR_ENTRY_TITLE, "Unmatched Leaf"));
}
/** Case 11: Expected match. */
@Test
public void testReadObjectByParent11()
{
assertNotNull("Case 11: Expected match.", testBaseSpringHibernateDAOEntryImpl.readObjectByParent(ATTR_BRANCH,
ATTR_BRANCH_ID, ID_1ST_TST_BRANCH, ATTR_ENTRY_TITLE, LEAF_ONE));
}
/**
* Test method for
* {@link com.philip.journal.core.dao.spring.hibernate.BaseDAOSpringHibernate#save(java.lang.Object)}.
*
* Case 1: Null argument.
*/
@Test(expected = JournalException.class)
public void testSaveCase1()
{
testBaseSpringHibernateDAOEntryImpl.save(null);
}
@Override
protected final BaseDAOSpringHibernate<Entry> getTargetDAOImpl()
{
return testBaseSpringHibernateDAOEntryImpl;
}
}