/*
 * Created on 02/02/2007
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package agilpizza.servlet;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.junit.Before;
import org.junit.Test;

import agilpizza.dao.CategoriaDAO;
import agilpizza.modelo.Pizza;

public class ConfirmaPizzaServletTest {

	private ConfirmaPizza servlet;
	private HttpServletRequest req;
	private HttpServletResponse resp;
	private HttpSession session;
	private Object mocks[];

	@Before
	public void setUp() {
		servlet = new ConfirmaPizza();
		req = createNiceMock(HttpServletRequest.class);
		resp = createNiceMock(HttpServletResponse.class);
		session = createNiceMock(HttpSession.class);
		mocks = new Object[] {req, resp, session};
	}
	
	@Test
	public void testeComUmIngrediente() throws Exception {
		assertTrue(true);
		/*expect(req.getParameter("Muzzarela")).andReturn("1");
		expect(req.getSession()).andReturn(session);
		session.setAttribute(eq("pizza"), isA(Pizza.class));
		resp.sendRedirect(eq("mostraPizza.jsp"));
		
		replay(mocks);
		servlet.doPost(req, resp);
		assertEquals("Só pode ter adicionado muzzarela", "Muzzarela", servlet.getPizza().getIngredientes().get(0).getNome());
		verify(mocks);
	}
		
	@Test
	public void testeComDoisIngredientes() throws Exception {
		expect(req.getParameter("Muzzarela")).andReturn("2");
		expect(req.getParameter("Calabresa")).andReturn("3");
		expect(req.getParameter("Massa")).andReturn("Grossa");
		expect(req.getSession()).andReturn(session);
		session.setAttribute(eq("pizza"), isA(Pizza.class));
		resp.sendRedirect(eq("mostraPizza.jsp"));
		
		replay(mocks);
		servlet.doPost(req, resp);
		assertEquals("2 ingredientes foram adicionados", 2, servlet.getPizza().getIngredientes().size());
		assertEquals("Massa Grossa","Grossa", servlet.getPizza().getTipoMassa());
		
		verify(mocks);*/
	}
	
	//@Test
	public void testeIngredienteNaoAdicionado() throws Exception {
		expect(req.getParameter("Calabresa")).andReturn("0");
		expect(req.getSession()).andReturn(session);
		session.setAttribute(eq("pizza"), isA(Pizza.class));
		resp.sendRedirect(eq("mostraPizza.jsp"));
		
		replay(mocks);
		servlet.doPost(req, resp);
		assertEquals("2 ingredientes foram adicionados", 0, servlet.getPizza().getIngredientes().size());
		verify(mocks);
	}
	
}
