/**
 * 
 */
package org.richfaces.model;

import javax.el.ValueExpression;

import org.ajax4jsf.tests.MockValueExpression;

import junit.framework.TestCase;

/**
 * @author Konstantin Mishin
 *
 */
public class FilterFieldTest extends TestCase {

	private Field field;
	private ValueExpression expression;

	/**
	 * @param name
	 */
	public FilterFieldTest(String name) {
		super(name);
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
		expression = new MockValueExpression(null);
		field = new FilterField(expression);
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		field = null;
		expression = null;
		super.tearDown();
	}

	/**
	 * Test method for {@link org.richfaces.model.FilterField#FilterField(javax.el.ValueExpression)}.
	 */
	public final void testFilterField() {
		Field filterField = new FilterField(expression);
		assertEquals(filterField, field);
	}

	/**
	 * Test method for {@link org.richfaces.model.Field#hashCode()}.
	 */
	public final void testHashCode() {
		Field filterField = new FilterField(expression);
		assertEquals(filterField.hashCode(), field.hashCode());
	}

	/**
	 * Test method for {@link org.richfaces.model.Field#equals(java.lang.Object)}.
	 */
	public final void testEqualsObject() {
		Field filterField = new FilterField(null);
		assertFalse(filterField.equals(field));
		filterField.setExpression(expression);
		assertTrue(filterField.equals(field));
	}

	/**
	 * Test method for {@link org.richfaces.model.Field#getExpression()}.
	 */
	public final void testGetExpression() {
		assertSame(field.getExpression(), expression);
	}

	/**
	 * Test method for {@link org.richfaces.model.Field#setExpression(javax.el.ValueExpression)}.
	 */
	public final void testSetExpression() {
		field.setExpression(null);
		assertNull(field.getExpression());
	}

}
