Package br.com.caelum.stella.gateway.integration

Source Code of br.com.caelum.stella.gateway.integration.VISATestRetornoComponente

package br.com.caelum.stella.gateway.integration;

import javax.servlet.http.HttpServletRequest;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;

import br.com.caelum.stella.gateway.visa.VISAComponentReturnHandler;
import br.com.caelum.stella.gateway.visa.VISAIntegrationReturn;

/**
* Testa os possiveis de retorno
* @author Alberto Pc
*
*/
public class VISATestRetornoComponente {

  @Test
  public void testRetornoValidoDoCheckoutComLrIgualA00() {
    Mockery mockery = new Mockery();
    final HttpServletRequest request = mockery.mock(HttpServletRequest.class);   
    mockery.checking(new Expectations(){
      {       
        atLeast(1).of(request).getParameter("lr");will(returnValue("00"));               
      }
    });
    new VISAComponentReturnHandler(criarRetornoDeIntegracao(request)).check();   
    mockery.assertIsSatisfied();
  }

  @Test
  public void testRetornoValidoDoCheckoutComLrIgualA11() {
    Mockery mockery = new Mockery();
    final HttpServletRequest request = mockery.mock(HttpServletRequest.class);   
    mockery.checking(new Expectations(){
      {
        atLeast(1).of(request).getParameter("lr");will(returnValue("11"));                               
      }
    })
    new VISAComponentReturnHandler(criarRetornoDeIntegracao(request)).check();   
    mockery.assertIsSatisfied();
 
 
  private VISAIntegrationReturn criarRetornoDeIntegracao(final HttpServletRequest request) {
    return new VISAIntegrationReturn(){

      public String getArs() {
        // TODO Auto-generated method stub
        return "Não deve ser utilizado";
      }

      public int getLr() {
        // TODO Auto-generated method stub
        return Integer.valueOf(request.getParameter("lr"));
      }

      public String getTid() {
        // TODO Auto-generated method stub
        return "432743896";
      }
     
    };
  }
 
}
TOP

Related Classes of br.com.caelum.stella.gateway.integration.VISATestRetornoComponente

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.