c.setIgnoreCase(true);
c.setSingleRecord(true);
c.setDbName("myDB");
c.setAll();
c.setDistinct();
c.addSelectColumn(new ColumnImpl("Author", "NAME"));
c.addSelectColumn(new ColumnImpl("Author", "AUTHOR_ID"));
c.addDescendingOrderByColumn(new ColumnImpl("Author", "NAME"));
c.addAscendingOrderByColumn(new ColumnImpl("Author", "AUTHOR_ID"));
c.addAlias("Writer", "Author");
c.addAsColumn("AUTHOR_NAME", new ColumnImpl("Author", "NAME"));
c.addJoin(new ColumnImpl("Author", "AUTHOR_ID"), new ColumnImpl("Book", "AUTHOR_ID"), Criteria.INNER_JOIN);
c.add(new ColumnImpl("Author", "NAME"), "author%", Criteria.LIKE);
// Some direct Criterion checks
Criterion cn = c.getCriterion(new ColumnImpl("Author", "NAME"));
cn.setIgnoreCase(true);
assertEquals("author%", cn.getValue());
assertEquals(Criteria.LIKE, cn.getComparison());
Criterion cnDirectClone = (Criterion) SerializationUtils.clone(cn);
assertEquals(cn, cnDirectClone);
// Clone the object
Criteria cClone = (Criteria) SerializationUtils.clone(c);
// Check the clone
assertEquals(c.size(), cClone.size());
assertEquals(10, cClone.getOffset());
assertEquals(c.getOffset(), cClone.getOffset());
assertEquals(11, cClone.getLimit());
assertEquals(c.getLimit(), cClone.getLimit());
assertEquals(true, cClone.isIgnoreCase());
assertEquals(c.isIgnoreCase(), cClone.isIgnoreCase());
assertEquals(true, cClone.isSingleRecord());
assertEquals(c.isSingleRecord(), cClone.isSingleRecord());
assertEquals("myDB", cClone.getDbName());
assertEquals(c.getDbName(), cClone.getDbName());
List selectModifiersClone = cClone.getSelectModifiers();
assertTrue(selectModifiersClone.contains(Criteria.ALL.toString()));
assertTrue(selectModifiersClone.contains(Criteria.DISTINCT.toString()));
assertEquals(c.getSelectModifiers(), cClone.getSelectModifiers());
List selectColumnsClone = cClone.getSelectColumns();
assertTrue(selectColumnsClone.contains(new ColumnImpl("Author", "NAME")));
assertTrue(selectColumnsClone.contains(new ColumnImpl("Author", "AUTHOR_ID")));
assertEquals(c.getSelectColumns(), cClone.getSelectColumns());
List orderByColumnsClone = cClone.getOrderByColumns();
assertTrue(orderByColumnsClone.contains(new OrderBy(new ColumnImpl("Author.NAME"), SqlEnum.DESC, false)));
assertTrue(orderByColumnsClone.contains(new OrderBy(new ColumnImpl("Author.AUTHOR_ID"), SqlEnum.ASC, false)));
assertEquals(c.getOrderByColumns(), cClone.getOrderByColumns());
Map aliasesClone = cClone.getAliases();
assertTrue(aliasesClone.containsKey("Writer"));
assertEquals("Author", aliasesClone.get("Writer"));
assertEquals(c.getAliases(), cClone.getAliases());
Map asColumnsClone = cClone.getAsColumns();
assertTrue(asColumnsClone.containsKey("AUTHOR_NAME"));
assertEquals(new ColumnImpl("Author", "NAME"), asColumnsClone.get("AUTHOR_NAME"));
assertEquals(c.getAsColumns(), cClone.getAsColumns());
// Check Joins
List joinsClone = cClone.getJoins();
Join joinClone = (Join) joinsClone.get(0);
assertEquals(
new ColumnImpl("Author", "AUTHOR_ID"),
joinClone.getJoinCondition().getLValue());
assertEquals(new ColumnImpl("Book", "AUTHOR_ID"),
joinClone.getJoinCondition().getRValue());
assertEquals(Criteria.INNER_JOIN, joinClone.getJoinType());
assertEquals(c.getJoins(), cClone.getJoins());
// Some Criterion checks
Criterion cnClone = cClone.getCriterion(new ColumnImpl("Author", "NAME"));
assertEquals("author%", cnClone.getValue());
assertEquals(Criteria.LIKE, cnClone.getComparison());
assertEquals(cn.isIgnoreCase(), cnClone.isIgnoreCase());
// Confirm that equals() checks all of the above.