Java - Mockito's When () function. ThenReturn ()

1
@Mock
RequestUtils requestUtils;
    @Before
    public void init() throws IOException, ClassNotFoundException {
        MockitoAnnotations.initMocks(this);
        HtmlPage paginaPesquisa = requestUtils.executarPOST(anyObject(),anyObject());
        when(paginaPesquisa).thenReturn(this.getPaginaEstatica(URL_PESQUISA, PAGINA_RESULTADOS_PESQUISA_NOME, "ISO-8859-1" ));
        when(requestUtils.getPaginaResultados(anyObject())).thenReturn(this.getPaginaEstatica(URL_PESQUISA,PAGINA_RESULTADOS_PESQUISA_IDADE, "ISO-8859-1"));
        when(paginaPesquisa.getWebClient().getPage(anyObject().toString())).thenReturn(this.getPaginaEstatica(URL_PAGINA_INICIAL,PAGINA_INICIAL,"ISO-8859-1"));
    }

The problem is that in the latter when:

when(paginaPesquisa.getWebClient().getPage(anyObject().toString()))

Give NullPointerException because you can not even webClient .

I looked for Mockito functions for this case but found nothing ... What to do?

    
asked by anonymous 29.09.2017 / 15:05

0 answers